@nogc hash
Guillaume Piolat via Digitalmars-d
digitalmars-d at puremagic.com
Fri Sep 9 06:54:21 PDT 2016
On Friday, 9 September 2016 at 12:31:34 UTC, Marco Leise wrote:
> The point is that TypeInfo_*.getHash() cannot be @nogc,
> because a class or struct may implement a not- at nogc toHash().
> (Where I may add, that e.g. TypeInfo_Pointer.getHash() *could*
> be @nogc, since all it returns is `cast(size_t)cast(void*)p`).
>
> The alternatives in core.internal.hash are supposed to
> be CTFE-able and albeit bytesHash itself does not seem to use
> the GC, the wrapper functions for different types may.
>
> And that is why @nogc hash table implementations don't fly at
> the moment.
Yeah it wouldn't be far-fetched to make toHash() @nogc nothrow.
A hash-table that allocates on lookup would negate any
speed-advantage anyway.
More information about the Digitalmars-d
mailing list