Skip to content

Commit e1d4ce7

Browse files
committed
Only use MakeGenericMethod when it is necessary
1 parent 6cf5c05 commit e1d4ce7

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/SQLite.cs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,17 +3010,24 @@ public IEnumerable<T> ExecuteDeferredQuery<T> (TableMapping map)
30103010
{
30113011
Array.Copy(map.Columns, cols, Math.Min(cols.Length, map.Columns.Length));
30123012
}
3013-
else if (map.Method == TableMapping.MapMethod.ByName)
3014-
{
3015-
var getSetter = typeof(FastColumnSetter)
3013+
else if (map.Method == TableMapping.MapMethod.ByName) {
3014+
MethodInfo getSetter = null;
3015+
if (typeof(T) != map.MappedType) {
3016+
getSetter = typeof(FastColumnSetter)
30163017
.GetMethod (nameof(FastColumnSetter.GetFastSetter),
3017-
BindingFlags.NonPublic | BindingFlags.Static).MakeGenericMethod (map.MappedType);
3018-
3018+
BindingFlags.NonPublic | BindingFlags.Static).MakeGenericMethod (map.MappedType);
3019+
}
3020+
30193021
for (int i = 0; i < cols.Length; i++) {
30203022
var name = SQLite3.ColumnName16 (stmt, i);
30213023
cols[i] = map.FindColumn (name);
30223024
if (cols[i] != null)
3023-
fastColumnSetters[i] = (Action<object, Sqlite3Statement, int>)getSetter.Invoke(null, new object[]{ _conn, cols[i]});
3025+
if (getSetter != null) {
3026+
fastColumnSetters[i] = (Action<object, Sqlite3Statement, int>)getSetter.Invoke(null, new object[]{ _conn, cols[i]});
3027+
}
3028+
else {
3029+
fastColumnSetters[i] = FastColumnSetter.GetFastSetter<T>(_conn, cols[i]);
3030+
}
30243031
}
30253032
}
30263033

0 commit comments

Comments
 (0)