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()
Undocumented in source.
this
this(size_t bucketCount)

Destructor

~this
~this()
Undocumented in source.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Functions

allocated
size_t allocated()
Undocumented in source. Be warned that the author may not have intended to support it.
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