#550·xxHash

Simple source code to integrate

Author: Cyan4973Created Aug 9, 2021Updated Jul 16, 2023
LabelsLong-term

One of the strong points of xxhash is its integration story : it's enough to grab a single file xxhash.h and there you have the entire library available in your program.

However, this only applies to people who trust the source code. In some cases, when a programmer feels he should inspect the source code before integration, the large source size of xxhash.h can feel daunting by itself.

One idea could be to split the source code into more dedicated units, resulting in more focused code bases. If someone is only interested in XXH32() or XXH64(), they could integrate, or even copy/paste, just this code. A good example of this strategy is Stefan Brumme's simple xxHash C++ libraries. To reach the same level of clarity,XXH3 would have to be split even further, alongside its vector variants. And of course, one-shot and streaming variants would preferably be separated too.

This could work. But it would also result in a more complex multi-files code base, making the integration story more difficult.

A potential work-around could be to split the source code into these dedicated units, and then have an automated build system which regenerates the "complete" amalgamated xxhash.h library, so that current user base can still benefit from the 1-file integration story.

Splitting is not too difficult, though requires quite some work, hence some available time. The amalgamation process can be a bit more tricky, especially if an important objective is that xxhash.h must remain an approachable source file which can be read and debugged, as readability experience can be hurt by a dumb amalgamation process.

Supersedes #543.