@@ -785,15 +785,16 @@ function subfieldConflicts(
785
785
* not matter. We do this by maintaining a sort of double adjacency sets.
786
786
*/
787
787
class PairSet {
788
- _data : ObjMap < ObjMap < boolean > > ;
788
+ _data : Map < string , Map < string , boolean > > ;
789
789
790
790
constructor ( ) {
791
- this . _data = Object . create ( null ) ;
791
+ this . _data = new Map ( ) ;
792
792
}
793
793
794
794
has ( a : string , b : string , areMutuallyExclusive : boolean ) : boolean {
795
- const first = this . _data [ a ] ;
796
- const result = first && first [ b ] ;
795
+ const [ key1 , key2 ] = a < b ? [ a , b ] : [ b , a ] ;
796
+
797
+ const result = this . _data . get ( key1 ) ?. get ( key2 ) ;
797
798
if ( result === undefined ) {
798
799
return false ;
799
800
}
@@ -807,16 +808,13 @@ class PairSet {
807
808
}
808
809
809
810
add ( a : string , b : string , areMutuallyExclusive : boolean ) : void {
810
- this . _pairSetAdd ( a , b , areMutuallyExclusive ) ;
811
- this . _pairSetAdd ( b , a , areMutuallyExclusive ) ;
812
- }
811
+ const [ key1 , key2 ] = a < b ? [ a , b ] : [ b , a ] ;
813
812
814
- _pairSetAdd ( a : string , b : string , areMutuallyExclusive : boolean ) : void {
815
- let map = this . _data [ a ] ;
816
- if ( ! map ) {
817
- map = Object . create ( null ) ;
818
- this . _data [ a ] = map ;
813
+ const map = this . _data . get ( key1 ) ;
814
+ if ( map === undefined ) {
815
+ this . _data . set ( key1 , new Map ( [ [ key2 , areMutuallyExclusive ] ] ) ) ;
816
+ } else {
817
+ map . set ( key2 , areMutuallyExclusive ) ;
819
818
}
820
- map [ b ] = areMutuallyExclusive ;
821
819
}
822
820
}
0 commit comments