https://issues.dlang.org/show_bug.cgi?id=17526

--- Comment #5 from Vladimir Panteleev <[email protected]> ---
BTW, the performance use case of the proposed set method (which I called
getOrAdd in my hashmap implementation):

struct S { int i, j, k, l, m; /* etc. */ }
S[int] aa;

// The goal is to increment aa[x].k
// If aa[x] doesn't exist, initialize it with S.init
// Currently, you have to do this:

if (auto p = x in aa)
    (*p).k++;
else
{
    S s;
    s.k = 1;
    aa[x] = s;  // Wasteful - double lookup
}

--

Reply via email to