Skip to content

Commit 1148bd4

Browse files
committed
Add a small note about modulo constants
1 parent 961c2a8 commit 1148bd4

File tree

3 files changed

+3
-5
lines changed

3 files changed

+3
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ There are many benefits gained from generating data structures at compile time:
220220
* Enables otherwise time-consuming data analysis (e.g. zero runtime overhead)
221221
* No defensive copying of data (takes time and needs double the memory)
222222
* No virtual dispatching (virtual method calls & inheritance) and no unnecessary branching
223+
* Modulo operations are known constants and compilers optimize it to bitwise operations
223224

224225
### Data analysis
225226

Src/FastData/FastDataGenerator.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,10 @@ public static string Generate<T>(ReadOnlySpan<T> data, FastDataConfig fdCfg, ICo
9494
}
9595

9696
ILogger logger = factory.CreateLogger(typeof(FastDataGenerator));
97+
LogUserStructureType(logger, fdCfg.StructureType);
9798
LogUniqueItems(logger, uniq.Count);
9899

99100
DataProperties<T> props = DataProperties<T>.Create(data);
100-
101101
LogDataType(logger, props.DataType);
102102

103103
if (props.FloatProps != null)
@@ -107,7 +107,6 @@ public static string Generate<T>(ReadOnlySpan<T> data, FastDataConfig fdCfg, ICo
107107
else if (props.StringProps != null)
108108
LogMinMaxLength(logger, props.StringProps.LengthData.Min, props.StringProps.LengthData.Max);
109109

110-
LogUserStructureType(logger, fdCfg.StructureType);
111110
GeneratorConfig<T> genCfg = new GeneratorConfig<T>(fdCfg.StructureType, DefaultStringComparison, props);
112111

113112
switch (fdCfg.StructureType)

Src/FastData/Internal/Misc/HashData.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ internal static HashData Create<T>(ReadOnlySpan<T> data, DataType dataType, int
1313
stringHash = new DefaultStringHash();
1414

1515
HashFunc<T> hashFunc;
16-
17-
//If we have a string hash, use it.
1816
if (stringHash == null)
1917
hashFunc = PrimitiveHash.GetHash<T>(dataType);
2018
else
@@ -24,7 +22,7 @@ internal static HashData Create<T>(ReadOnlySpan<T> data, DataType dataType, int
2422

2523
ulong[] hashCodes = new ulong[size];
2624
HashSet<ulong> uniqSet = new HashSet<ulong>();
27-
HashSet<ulong> perfectSet = new HashSet<ulong>(); //TOOD: Use direct addressing
25+
HashSet<ulong> perfectSet = new HashSet<ulong>(); //TODO: Use direct addressing
2826

2927
bool uniq = true;
3028
bool perfect = true;

0 commit comments

Comments
 (0)