Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions source/mir/string_map.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,21 @@ struct StringMap(T, U = uint)

///
// current implementation is workaround for linking bugs when used in self referencing algebraic types
bool opEquals(V)(scope const StringMap!(V, U) rhs) const
bool opEquals(V)(scope const StringMap!(V, U) rhs) const @trusted
{
// NOTE: moving this to template restriction fails with recursive template instanation
static assert(is(typeof(T.init == V.init) : bool),
"Unsupported rhs of type " ~ typeof(rhs).stringof);
if (keys != rhs.keys)
if (implementation is null)
return rhs.length == 0;
if (rhs.implementation is null)
return length == 0;
if (implementation._length != rhs.implementation._length)
return false;
if (implementation)
foreach (const i; 0 .. implementation._length)
if (implementation.values[i] != rhs.implementation.values[i]) // needs `values` instead of `_values` to be @safe
return false;
foreach (const i, const index; implementation.indices)
if (implementation._keys[index] != rhs.implementation._keys[rhs.implementation._indices[i]] ||
implementation._values[index] != rhs.implementation._values[rhs.implementation._indices[i]])
return false;
return true;
}
/// ditto
Expand Down Expand Up @@ -987,11 +991,11 @@ version(mir_test)
x["val"] = 1;
assert(x != y);

y["val"] = 1;
assert(x != y);
y["L"] = 3;
assert(x != y);
y["A"] = 2;
assert(x != y);
y["val"] = 1;
assert(x == y);

x = X.init;
Expand Down