Minimising Squirrel Code - Why does this work?

Hi guys,

We’ve been experimenting with minimising squirrel code to improve our code density as we’re often running out of a space (a discussion for another day perhaps but built-in minimisation at compile time or run-time library support would be amazing), we’ve tried using the program JSMIN ( and have found that this can save ~4-5% from the compiled code size.

The thing is, we don’t know why. JSMIN is not supposed to touch anything within quotes or regex and doesn’t modify function or variable names, all it does is replace \r with \n, reduce multiple spaces and linefeeds to 1, replace tabs and other control characters with 1 space and removes comments, all outside of quoted strings.

All I can think of is that there’s additional debug or trace information injected relating purely to the number of lines? Any ideas?

Many thanks

Line markers do take space - I believe only lines with executable code on them, though. This is for future source-level debugging.

We have some experimental internal tools which can likely answer this question, and perhaps point out further code size savings (like trivial statically unreachable code). If you file a support ticket with both your pre- and post-minimised squirrel I’ll take a look.

Thanks both, I’ll follow-up next week. On a side-note, are there any plans to improve code-space or allow for modular loading of code in the near-mid future?

Many thanks

There are plans to double code space on imps that are capable of supporting it, ie impC001 and imp006. We are also looking at doing the same for imp005, though there you’d be sacrificing 256kB of RAM for 256kB of code space.

The current schedule has this arriving in release 44, so a little while yet (though we’re trying to work out how to crank releases out quicker)