<HTML>
<style> BODY { font-family:Arial, Helvetica, sans-serif;font-size:12px; }</style>Hi everyone,<br>
<br>
<div>Sorry if the title sounds like a clickbait you find everywhere on the Internet, and I apologise again for using FPC as my kind of personal research ground!</div><div><br>
</div><div>I've just submitted a patch that uses a cheap, customised encoding system to minimise the number of bytes required to store fields in PPU files that are used to store indices, data lengths and offsets... integer values that are frequently small but nonetheless have a large domain (e.g. LongInt or QWord). I've submitted a number of patches here - https://bugs.freepascal.org/view.php?id=35299 - and the PPU file size is about 10% smaller. For large projects like Lazarus, this amounts to over 10 megabytes.</div><div><br>
</div><div>I admit that storage space isn't a premium on most systems these days, but for things like embedded systems, then every little helps.<br>
</div><div><br>
</div><div>The encoding system I've named "Varlen" and the technical details can be found here: <a href="http://wiki.freepascal.org/Varlen_Encoding">http://wiki.freepascal.org/Varlen_Encoding</a></div><div><br>
</div><div>The basic idea is that values close to zero take fewer bytes to store than values near the top of the QWord domain. Values between 0 and 127, for example, only require a single byte as opposed to 4 or 8, making it highly suitable for offsets, counts and length fields, especially if they are frequently equal to zero. Conversely, Varlen is not suitable for things like pointers and hashes, whose literal values can be very large.</div><div><br>
</div><div>One thing not mentioned but pointed out by another developer is that, unlike something like LEB128, there is no way for a Varlen to encode an endless byte stream, so if a PPU file gets corrupted, there's no way it will put the compiler into an infinite loop or a dangerous resource starvation situation.<br>
</div><div><br>
</div><div>What do you guys think?</div><div><br>
</div><div>Gareth aka. Kit<br>
</div> </HTML>