StringCache

The string cache is used for string interning.

It will only story a single copy of any string that it is asked to hold. Interned strings can be compared for equality by comparing their .ptr field.

Default and postbilt constructors are disabled. When a StringCache goes out of scope, the memory held by it is freed.

Constructors

this
this(size_t bucketCount)

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Postblit

A postblit is present on this object, but not explicitly documented in the source.

Members

Functions

intern
string intern(const(ubyte)[] str)
string intern(string str)

Caches a string.

intern
string intern(const(ubyte)[] str, uint hash)

Caches a string as above, but uses the given hash code instead of calculating one itself. Use this alongside hashStep() can reduce the amount of work necessary when lexing dynamic tokens.

Static functions

hashStep
uint hashStep(ubyte b, uint h)

Incremental hashing.

Static variables

defaultBucketCount
enum defaultBucketCount;

The default bucket count for the string cache.

See Also

Meta