A fast mostly collision free hash ?

Jean-Marc Lasgouttes lasgouttes at lyx.org
Tue Nov 8 15:43:15 UTC 2022


Hi everyone,

Currently we use QCache container that remember the size, layout or line 
breaking points of some strings from the document. Basically, a key is 
mapped to an object.

However currently the key contains the strings, which means that 
globally all the document is duplicated as cache keys. This is quite a 
waste.

What would be a good way to replace the string by a good enough signature?

* qHash is designed to have some collisions (which are handled by the 
container); this is not good.
* boost::crc can be used too, but it is supposed to do something else
* would using a sha1 or a md5 make sense?
* I could do fancy things, but I'd rather avoid to import a whole 
library for this.

I am not looking for something that is strong against malicious attacks, 
but rather something that is fast and works in practice.

Ideas?

JMarc


More information about the lyx-devel mailing list