@@ -101,7 +101,8 @@ export function createCommonFields(batches: Batch[]): CommonField[] {
101101
102102function sourceTagsFromBatchesAndAssetNames (
103103 batches : Batch [ ] , assetNames : string [ ] ) : Map < string , Set < string > > {
104- const sourceTags = new Map < string , Set < string > > ( ) ;
104+ const tagToAssetNames = new Map < string , Set < string > > ( ) ;
105+ const tagToBitmask = new Map < string , string > ( ) ;
105106
106107 for ( const batch of batches ) {
107108 const constant =
@@ -117,24 +118,22 @@ function sourceTagsFromBatchesAndAssetNames(
117118 const tag = tagAndBitmaskSplit [ 0 ] ;
118119 const bitmask = tagAndBitmaskSplit [ 1 ] ;
119120
120- const taggedAssetNames = new Set < string > ( ) ;
121- if ( ! applyBitmaskToStringArray ( assetNames , bitmask , taggedAssetNames ) ) {
122- // Mismatch between the asset names and a bitmask.
123- return new Map < string , Set < string > > ( ) ;
124- }
125-
126- const oldTaggedAssetNames = sourceTags . get ( tag ) ;
127- if ( oldTaggedAssetNames !== undefined ) {
128- if ( oldTaggedAssetNames !== taggedAssetNames ) {
129- // Mismatch between batches about the meaning of a tag.
121+ const otherBitmask = tagToBitmask . get ( tag ) ;
122+ if ( otherBitmask === undefined ) {
123+ const taggedAssetNames = new Set < string > ( ) ;
124+ if ( ! applyBitmaskToStringArray ( assetNames , bitmask , taggedAssetNames ) ) {
125+ // Mismatch between the asset names and a bitmask.
130126 return new Map < string , Set < string > > ( ) ;
131127 }
132- } else {
133- sourceTags . set ( tag , taggedAssetNames ) ;
128+ tagToAssetNames . set ( tag , taggedAssetNames ) ;
129+ tagToBitmask . set ( tag , bitmask ) ;
130+ } else if ( otherBitmask !== bitmask ) {
131+ // Mismatch between batches about the meaning of a tag.
132+ return new Map < string , Set < string > > ( ) ;
134133 }
135134 }
136135 }
137- return sourceTags ;
136+ return tagToAssetNames ;
138137}
139138
140139/**
0 commit comments