espruino / Espruino

The Espruino JavaScript interpreter - Official Repo
http://www.espruino.com/
Other
2.73k stars 741 forks source link

'Linting' for potential inefficiencies #2462

Open gfwilliams opened 5 months ago

gfwilliams commented 5 months ago

In Espruino we have quite a few functions that do multiple things...

eg:

jsvObjectSetChild(obj, "name", child);
jsvUnLock(child);

turns into:

jsvObjectSetChildAndUnLock(obj, "name", child);

Which for something that's used a lot can end up saving an awful lot of flash.

Ideally we should be able to have a list of these, and then run over the code and detect when code exists that uses the first pattern when it should use the second.

We have ... make lst; scripts/find_common_code.js bin/projectname.lst at the moment which looks at the final built code and has helped to detect glaring issues, but this doesn't stop new uses of the old pattern coming in which over time can add up to waste a lot of space.

gfwilliams commented 1 month ago

https://github.com/M4GNV5/cparse might work here