File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Expand file tree Collapse file tree 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)
3838
3939 // /
4040 // 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
4242 {
4343 // NOTE: moving this to template restriction fails with recursive template instanation
4444 static assert (is (typeof (T.init == V.init) : bool ),
4545 " 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)
4751 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 ;
5256 return true ;
5357 }
5458 // / ditto
@@ -987,11 +991,11 @@ version(mir_test)
987991 x[" val" ] = 1 ;
988992 assert (x != y);
989993
994+ y[" val" ] = 1 ;
995+ assert (x != y);
990996 y[" L" ] = 3 ;
991997 assert (x != y);
992998 y[" A" ] = 2 ;
993- assert (x != y);
994- y[" val" ] = 1 ;
995999 assert (x == y);
9961000
9971001 x = X.init;
You can’t perform that action at this time.
0 commit comments