lua-users home
lua-l archive

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


> Profiling this it seems as though this is the most performant solution
> because there are not that many subscriptions and our software runs on
> pretty constrained hardware (mostly NodeMCU and similar).

If you are worried about memory usage then my solution involved creating and then comparing against (via __eq) two strings, namely “/sport” and “/sport/“.

You could rewrite it something like this, where the string to match against is only stored once:

X:sub(1,6) == “/sport” and (#X == 6 or X:sub(7,7):byte() == 0x2F)

Is NodeMCU still a thing? It seemed to run out of steam a couple of years ago, still talking about how a port to ESP32 was in the works and more hardware support was being added (e.g. Bluetooth).

(I switched, with a tiny bit of regret, to micropython, which seems to have a much more active community.)