On Friday, 20 April 2018 at 08:37:59 UTC, Nick Treleaven wrote:
Again, would the delegate calls always be inlined, in all cases?

I think having a low-level API in druntime is appropriate, it's a runtime library after all.

So the low-level API you are requesting is part of the pull request, the low-level API is called _aaGetX, whereas the previous API was _aaGetY, the new API adds a boolean out parameter `found` and if you really wanted to you could do this:

-----
extern (C) void* _aaGetX(void** paa, const TypeInfo_AssociativeArray ti, in size_t valuesize, in void* pkey, out bool found) pure nothrow;

V* slot(K, V)(ref V[K] aa, K key, out bool found)
{
return cast(V*) _aaGetX(cast(void**)&aa, typeid(V[K]), V.sizeof, &key, found);
}
-----

I am also benchmarking the `update` function I talked about previously.
https://gist.github.com/GilesBathgate/8409b5889ebb7b1302627c50f342a28b

The results seem to indicate that there isn't much in it performance wise.

test1 [56 ms, 377 µs, and 4 hnsecs]
test2 [56 ms, 262 µs, and 2 hnsecs]

I can't fathom why the delegates version is faster, but I am just putting it down to luck ;)

Reply via email to