lua-users home
lua-l archive

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


Yes, this is what I went with in the end plus some edge case checks.
Memory is not a problem (contrary to my initial assumption) since there
are usually not more than 10 subscribers.

NodeMCU might be no longer the hot new kid on the block but in our field
(niche retrofit automations) they still go strong. If it ain't broken,
don't fix it :)

Cheers
Tristan

On 15/12/2022 19:26, Paul Ducklin wrote:
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.)