Skip to content

Commit bb2eb2e

Browse files
committed
Eliminate redundant code; clarify method prerequisites.
1 parent 20e830c commit bb2eb2e

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

src/MySqlConnector/MySqlParameterCollection.cs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,12 @@ protected override DbParameter GetParameter(string parameterName)
9090

9191
// Finds the index of a parameter by name, regardless of whether 'parameterName' or the matching
9292
// MySqlParameter.ParameterName has a leading '?' or '@'.
93-
internal int NormalizedIndexOf(string? parameterName)
94-
{
95-
var normalizedName = MySqlParameter.NormalizeParameterName(parameterName ?? "");
96-
return m_nameToIndex.TryGetValue(normalizedName, out var index) ? index : -1;
97-
}
93+
internal int NormalizedIndexOf(string? parameterName) =>
94+
UnsafeIndexOf(MySqlParameter.NormalizeParameterName(parameterName ?? ""));
9895

99-
internal int UnsafeIndexOf(string? normalizedParameterName)
100-
{
101-
return m_nameToIndex.TryGetValue(normalizedParameterName ?? "", out var index) ? index : -1;
102-
}
96+
// Finds the index of a parameter by normalized name (i.e., the results of MySqlParameter.NormalizeParameterName).
97+
internal int UnsafeIndexOf(string? normalizedParameterName) =>
98+
m_nameToIndex.TryGetValue(normalizedParameterName ?? "", out var index) ? index : -1;
10399

104100
public override void Insert(int index, object value) => AddParameter((MySqlParameter) (value ?? throw new ArgumentNullException(nameof(value))), index);
105101

0 commit comments

Comments
 (0)