Skip to content

Commit

Permalink
Revert "Cache name-hashes in a static var, makes subsequent calls muc…
Browse files Browse the repository at this point in the history
…h faster"

This reverts commit e11abf2.
  • Loading branch information
alex-jitbit committed Nov 28, 2022
1 parent 4e7383a commit 94efe29
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions MapDataReader/MapperGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,19 @@ private static void SetPropertyByName(this {typeNodeSymbol.FullName()} target, i
if (typeNodeSymbol.InstanceConstructors.Any(c => !c.Parameters.Any())) //has a constructor without parameters?
{
src += $@"
private static int[] _columnNameHashes{typeNode.Identifier} = null;
public static List<{typeNodeSymbol.FullName()}> To{typeNode.Identifier}(this IDataReader dr)
{{
var list = new List<{typeNodeSymbol.FullName()}>();
if (dr.Read())
{{
if(_columnNameHashes{typeNode.Identifier} == null)
_columnNameHashes{typeNode.Identifier} = Enumerable.Range(0, dr.FieldCount).Select(i => MapperGenerator.GetDeterministicHashCode(dr.GetName(i))).ToArray();
int[] columnNameHashes = Enumerable.Range(0, dr.FieldCount).Select(i => MapperGenerator.GetDeterministicHashCode(dr.GetName(i))).ToArray();
do
{{
var result = new {typeNodeSymbol.FullName()}();
int i = 0;
foreach (var col in _columnNameHashes{typeNode.Identifier})
foreach (var col in columnNameHashes)
{{
var value = dr[i];
if (value is DBNull) value = null;
Expand Down

0 comments on commit 94efe29

Please sign in to comment.