Function optimalBucketCount
Helper function used to avoid too much allocations while lexing.
ulong optimalBucketCount
(
ulong size
);
Parameters
Name | Description |
---|---|
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);
static if (size_t .sizeof == ulong .sizeof)
assert(optimalBucketCount(100_000_000_000UL) == 1 << 30);