File tree 1 file changed +12
-8
lines changed
1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -38,17 +38,21 @@ struct StringMap(T, U = uint)
38
38
39
39
// /
40
40
// current implementation is workaround for linking bugs when used in self referencing algebraic types
41
- bool opEquals (V)(scope const StringMap! (V, U) rhs) const
41
+ bool opEquals (V)(scope const StringMap! (V, U) rhs) const @trusted
42
42
{
43
43
// NOTE: moving this to template restriction fails with recursive template instanation
44
44
static assert (is (typeof (T.init == V.init) : bool ),
45
45
" Unsupported rhs of type " ~ typeof (rhs).stringof);
46
- if (keys != rhs.keys )
46
+ if (implementation is null )
47
+ return rhs.length == 0 ;
48
+ if (rhs.implementation is null )
49
+ return length == 0 ;
50
+ if (implementation._length != rhs.implementation._length)
47
51
return false ;
48
- if ( implementation)
49
- foreach ( const i; 0 .. implementation._length)
50
- if ( implementation.values [i ] != rhs.implementation.values [i]) // needs `values` instead of `_values` to be @safe
51
- return false ;
52
+ foreach ( const i, const index; implementation.indices )
53
+ if (implementation._keys[index] != rhs.implementation._keys[rhs. implementation._indices[i]] ||
54
+ implementation._values[index ] != rhs.implementation._values[rhs.implementation._indices[i]])
55
+ return false ;
52
56
return true ;
53
57
}
54
58
// / ditto
@@ -987,11 +991,11 @@ version(mir_test)
987
991
x[" val" ] = 1 ;
988
992
assert (x != y);
989
993
994
+ y[" val" ] = 1 ;
995
+ assert (x != y);
990
996
y[" L" ] = 3 ;
991
997
assert (x != y);
992
998
y[" A" ] = 2 ;
993
- assert (x != y);
994
- y[" val" ] = 1 ;
995
999
assert (x == y);
996
1000
997
1001
x = X.init;
You can’t perform that action at this time.
0 commit comments