Okay, so it’s not a big deal now but it’s gonna be a big deal later.
I enjoy byte packing and speed optimization. It’s fun and satisfying, so that’s the actual goal here; practicality value is kinda arbitrary here.
I have a separate program written in JavaScript for Node.js (I know, hold on) because it can crunch numbers a lot faster than TADS can, so I have this separate program generating a large set of values as TADS 3 Vector
declaration code, which I drop into the game code as a method that runs during execute()
on a PreinitObject
.
However…while this is 32kB of cache memory, would this also be saved to the game file in the form of instructions, because the method that caches the Vector
is being saved as characters to the game file as well?
So I tried using setMethod(prop, method)
to assign an empty method to what creates the cache. Then I run t3RunGC()
. The idea is the old method with all the values saved as assignment instructions should get tossed to garbage collection before the preinit cache is done being written.
I compared the sizes of the files (outside of debug mode), and the difference is only a few bytes, which are probably the addition of the the setMethod
instruction, and the garbage collection call.
So…is there a way to keep methods from making it into the game file, after preinit is done? Right now this would only save me at least 32kB, but I have other data that I plan to also build in an external program, which will probably be a lot larger in size.
In a world where AAA games are GB in size, this is all meaningless, but it matters to my personal design goals, and also: it’s still fun.
Should I try to compile a version that lacks this cache entirely (method with declaration and all), and see what the size difference is? If it’s only 32-40kB of a difference, then maybe these methods are not becoming game instructions in the final file? If it’s a difference of 72kB or more, then that’s probably both the cache and the declaration method instructions.
While I know how a lot works, this is specifically an area of uncertainty.
EDIT: Wait a moment, is it possible to pack any kind of file into the final game file, similar to multimedia resources? I’d include the cache as a file and skip the declaration method, but only if it’s possible to make it part of the game file. I’m always kinda wary of having to include multiple files alongside something I plan to distribute; it’s much simpler to just have the one game file.