
On Thu, Dec 5, 2024 at 10:53 PM Andrey Semashev via Boost < boost@lists.boost.org> wrote:
Technically, it doesn't need to be size to separate the two fields. You can use any kind of separator, including a fixed one (i.e. not depending on either of the fields it separates). I.e. instead of this:
"ab" | 2 | "c" | 1
you could have this:
"ab" | separator_t{} | "c" | separator_t{}
An empty sequence could simply be hashed as separator_t{}.
The question is how separator_t would hash and whether it could be made any faster than just hashing the size. I suppose, it could be smaller (e.g. 1 byte of data instead of sizeof(size_t)), but I'm not sure if that would mean anything in terms of performance.
As far as I understand that will not work. Assume separator is char 'x' although it does not really matter what the value is, it is just for ease of writing. now "a" | "xc" hashes same as "ax" | "c" because both produce axxc