Function optimalBucketCount

Helper function used to avoid too much allocations while lexing.

ulong optimalBucketCount (
  ulong size
);

Parameters

NameDescription
size The length in bytes of the source file.

Returns

The optimal initial bucket count a StringCache should have.

Example

assert(optimalBucketCount(1) == 2);
assert(optimalBucketCount(9000 * 32) == 16384);
assert(optimalBucketCount(100_000_000_000UL) == 1 << 30);