@@ -107,7 +107,7 @@ public static GeneratorSpec Generate<T>(Func<string, ICodeGenerator> func, TestV
107107 props = DataAnalyzer . GetValueProperties ( span , dataType ) ;
108108
109109 ICodeGenerator generator = func ( vector . Identifier ) ;
110- bool useUTF16 = generator . UseUTF16Encoding ;
110+ GeneratorEncoding encoding = generator . Encoding ;
111111
112112 if ( vector . Type == typeof ( SingleValueStructure < > ) )
113113 return Generate ( generator , vector , props , dataType , StructureType . Auto , new SingleValueStructure < T > ( ) ) ;
@@ -120,25 +120,25 @@ public static GeneratorSpec Generate<T>(Func<string, ICodeGenerator> func, TestV
120120 if ( vector . Type == typeof ( EytzingerSearchStructure < > ) )
121121 return Generate ( generator , vector , props , dataType , StructureType . BinarySearch , new EytzingerSearchStructure < T > ( dataType , StringComparison . Ordinal ) ) ;
122122 if ( vector . Type == typeof ( HashSetChainStructure < > ) )
123- return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetChainStructure < T > ( GetHashData ( vector , dataType , useUTF16 ) , dataType ) ) ;
123+ return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetChainStructure < T > ( GetHashData ( vector , dataType , encoding ) , dataType ) ) ;
124124 if ( vector . Type == typeof ( HashSetPerfectStructure < > ) )
125- return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetPerfectStructure < T > ( GetHashData ( vector , dataType , useUTF16 ) , dataType ) ) ;
125+ return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetPerfectStructure < T > ( GetHashData ( vector , dataType , encoding ) , dataType ) ) ;
126126 if ( vector . Type == typeof ( HashSetLinearStructure < > ) )
127- return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetLinearStructure < T > ( GetHashData ( vector , dataType , useUTF16 ) ) ) ;
127+ return Generate ( generator , vector , props , dataType , StructureType . HashSet , new HashSetLinearStructure < T > ( GetHashData ( vector , dataType , encoding ) ) ) ;
128128 if ( vector . Type == typeof ( KeyLengthStructure < > ) )
129129 return Generate ( generator , vector , props , dataType , StructureType . Auto , new KeyLengthStructure < T > ( ( StringProperties ) props ) ) ;
130130
131131 throw new InvalidOperationException ( "Unsupported structure type: " + vector . Type . Name ) ;
132132 }
133133
134- private static HashData GetHashData < T > ( TestVector < T > vector , DataType dataType , bool useUTF16 ) where T : notnull
134+ private static HashData GetHashData < T > ( TestVector < T > vector , DataType dataType , GeneratorEncoding genEnc ) where T : notnull
135135 {
136136 HashData hashData ;
137137
138138 if ( dataType == DataType . String )
139139 {
140- Encoding encoding = useUTF16 ? Encoding . Unicode : Encoding . UTF8 ;
141- StringHashFunc func = DefaultStringHash . GetInstance ( useUTF16 ) . GetExpression ( ) . Compile ( ) ;
140+ Encoding encoding = genEnc == GeneratorEncoding . UTF8 ? Encoding . UTF8 : Encoding . Unicode ;
141+ StringHashFunc func = DefaultStringHash . GetInstance ( genEnc ) . GetExpression ( ) . Compile ( ) ;
142142
143143 hashData = HashData . Create < T > ( vector . Values . AsSpan ( ) , 1 , obj =>
144144 {
@@ -161,7 +161,7 @@ private static GeneratorSpec Generate<T, TContext>(ICodeGenerator generator, Tes
161161 HashDetails hashDetails = new HashDetails ( ) ;
162162
163163 if ( props is StringProperties stringProps )
164- genCfg = new GeneratorConfig < T > ( structureType , dataType , ( uint ) vector . Values . Length , stringProps , StringComparison . Ordinal , hashDetails , generator . UseUTF16Encoding ) ;
164+ genCfg = new GeneratorConfig < T > ( structureType , dataType , ( uint ) vector . Values . Length , stringProps , StringComparison . Ordinal , hashDetails , generator . Encoding ) ;
165165 else if ( props is ValueProperties < T > valueProps )
166166 {
167167 hashDetails . HasZeroOrNaN = valueProps . HasZeroOrNaN ;
0 commit comments