Skip to content

performance: remove unneeded ToArray calls #2174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Dapper.SqlBuilder/SqlBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public string ResolveClauses(DynamicParameters p)
.Union(new[]
{
" ( " +
string.Join(" OR ", this.Where(a => a.IsInclusive).Select(c => c.Sql).ToArray()) +
string.Join(" OR ", this.Where(a => a.IsInclusive).Select(c => c.Sql)) +
" ) "
}).ToArray()) + _postfix
: _prefix + string.Join(_joiner, this.Select(c => c.Sql).ToArray()) + _postfix;
})) + _postfix
: _prefix + string.Join(_joiner, this.Select(c => c.Sql)) + _postfix;
}
}

Expand Down
4 changes: 2 additions & 2 deletions Dapper/DynamicParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -397,10 +397,10 @@ static void ThrowInvalidChain()
}
while (diving is not null);

var dynamicParamName = string.Concat(names.ToArray());
var dynamicParamName = string.Concat(names);

// Before we get all emitty...
var lookup = string.Join("|", names.ToArray());
var lookup = string.Join("|", names);

var cache = CachedOutputSetters<T>.Cache;
var setter = (Action<object, DynamicParameters>?)cache[lookup];
Expand Down
2 changes: 1 addition & 1 deletion Dapper/SqlMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3498,7 +3498,7 @@ private static void GenerateDeserializerFromMap(Type type, DbDataReader reader,
var ctor = typeMap.FindConstructor(names, types);
if (ctor is null)
{
string proposedTypes = "(" + string.Join(", ", types.Select((t, i) => t.FullName + " " + names[i]).ToArray()) + ")";
string proposedTypes = "(" + string.Join(", ", types.Select((t, i) => t.FullName + " " + names[i])) + ")";
throw new InvalidOperationException($"A parameterless default constructor or one matching signature {proposedTypes} is required for {type.FullName} materialization");
}

Expand Down