lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Alexander Nasonov wrote:
> For some reason I can't use -j so I can only guess

You can replace e.g. -jv with the following command at runtime:


> Surely, string.find is not the
> greatest contributor but could it be that LuaJIT doesn't optimize
> a case of searching for a single char?

It doesn't compile any of the pattern matching functions. Checking
for a simple single-char match is possible, but that would be just
a workaround for a specific case. The real solution is to add a
pattern matching compiler. That's planned, but no ETA, yet.

> I search for the SOH and for the equal sign. I also do string.sub to
> get a tag and a value.

Much easier (and faster) to use a pattern with captures:

  for tag, val in string.gmatch(msg, "([^=\001]*)=([^\001]*)\001") do