Archive: Improvement to process_string


Improvement to process_string
Hi all!

Been lurking and using the fantastic NSIS for quite a while, thought it was time to give something back :)

I was browsing through the NSIS source code (as you do) and thought of a way to reduce the installer size a little, so gave it a go. The basic exehead remained the same size (although turns out to save 512 bytes when a packer such as UPX is used) but it gives a little more breathing space for future features. Basically just another case of getting the compiler to do more work and the exehead less...

So, here it is. The compiler converts references to variables (such as $INSTDIR and $STARTMENU) in strings to encoded versions ($A, $B, etc) so that the exehead doesn't need to know about their names. The expanding of variables in the installer is now a simple switch statement.

Here is a zip with a modified makensis.exe and two chunks of source code that made it.

Enjoy! :) and it would be great if it was deemed safe/good enough to merge in to the official NSIS ;)

--
Dave Laundon


Heh I have been thinking about this one for a while =) .. the main reason I didn't want to touch it was for fear of breaking a lot. But it would seem that it works :)

Anyway, I've also thought, why not use internally use non-standard values as the key, i.e. an ascii value of 1.

Since we don't have very many variables anyway, perhaps they should be encoded as 1-20 or 240-255 or something on those lines (which would simplify the exehead side even more, and make strings even smaller =)

Thoughts, comments?
-Justin


Originally posted by justin
Since we don't have very many variables anyway, perhaps they should be encoded as 1-20 or 240-255 or something on those lines (which would simplify the exehead side even more, and make strings even smaller =)
Aha! Hadn't thought of that.. Yes, then just have an escape character for the few times one of those actual characters is needed. Mmm, will try that...

Another thought for reducing size - turning virtually every string literal in the exehead into entries in the string-list, regardless of whether they might need to be overridden in a .nsi script or not. That way they'd benefit from the zlib compression. Exehead still probably won't change enough for it's .exe size to change, but UPX etc should be able to crunch it down a bit more?

--
Dave Laundon

I knew there'd be something.

Places in the compiler that read previously stored entries from the string list get the encoded versions. Not quite what's wanted... :(

--
Dave Laundon


Originally posted by eccles
I knew there'd be something.

Places in the compiler that read previously stored entries from the string list get the encoded versions. Not quite what's wanted... :(

--
Dave Laundon
True, but that doesn't happen too often; generally when it does, the compiler is copying a string from the installer string table to the uninstaller string table. And then, we could make it just do a direct copy. Right?

-justin

Originally posted by justin

True, but that doesn't happen too often; generally when it does, the compiler is copying a string from the installer string table to the uninstaller string table. And then, we could make it just do a direct copy. Right?

-justin
Mmm, yes.. but I've done it now.... :o

Just needs tidying up a bit, and is probably large enough to warrant a strlist.cpp now.

--
Dave Laundon

Right. Got round to finishing it at last...

Justin - source files changed to implement the more efficient variable system can be found here for your perusal. Everything appears to work...

Everyone else - love the gui's btw :cool: - sorry this isn't something similar, but smaller/faster installers is a good thing, right? :)

--
Dave Laundon


Yes, we all want faster and smaller installers :D