optimalBucketCount

Helper function used to avoid too much allocations while lexing.

size_t
optimalBucketCount
(
size_t size
)

Parameters

size size_t

The length in bytes of the source file.

Return Value

Type: size_t

The optimal initial bucket count a StringCache should have.

Examples

assert(optimalBucketCount(1) == 2);
assert(optimalBucketCount(9000 * 32) == 16384);
static if (size_t.sizeof == ulong.sizeof)
    assert(optimalBucketCount(100_000_000_000UL) == 1 << 30);

Meta