X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=turbopfor-encode.h;h=9341efc0b7f4c23552f29dbd115bac508eb6cc1d;hb=ae5100778b5b84f063b9b958ab8fe68da8b6e0ce;hp=532aa19d07b01faf6643f54153ac019387907d38;hpb=0f7ca618fb8a2e501fe68e1760de9ee716e37c40;p=plocate diff --git a/turbopfor-encode.h b/turbopfor-encode.h index 532aa19..9341efc 100644 --- a/turbopfor-encode.h +++ b/turbopfor-encode.h @@ -13,9 +13,11 @@ #include "turbopfor-common.h" +#include #include #include #include +#include template void write_le(Docid val, void *out) @@ -27,7 +29,7 @@ void write_le(Docid val, void *out) } else if constexpr (sizeof(Docid) == 2) { val = htole16(val); } else if constexpr (sizeof(Docid) == 1) { - val = val; + // No change. } else { assert(false); } @@ -50,6 +52,12 @@ unsigned char *write_baseval(Docid in, unsigned char *out) out[1] = in & 0xff; out[2] = (in >> 8) & 0xff; return out + 3; + } else if (in < 0x10000000) { + out[0] = (in >> 24) | 0xe0; + out[1] = (in >> 16) & 0xff; + out[2] = (in >> 8) & 0xff; + out[3] = in & 0xff; + return out + 4; } else { assert(false); // Not implemented. }