Skip to content

Commit

Permalink
Remove unnecessary reflection to create primitive type serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
Havret committed Jun 9, 2024
1 parent b40613f commit 6de300f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/RocksDb.Extensions/PrimitiveTypesSerializerFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ public ISerializer<T> CreateSerializer<T>()
var type = typeof(T);
if (type == typeof(int))
{
return (ISerializer<T>)Activator.CreateInstance(typeof(IntSerializer));
return (ISerializer<T>) new IntSerializer();
}
if (type == typeof(long))
{
return (ISerializer<T>)Activator.CreateInstance(typeof(LongSerializer));
return (ISerializer<T>) new LongSerializer();
}
if (type == typeof(string))
{
return (ISerializer<T>) Activator.CreateInstance(typeof(StringSerializer));
return (ISerializer<T>) new StringSerializer();
}
if (type == typeof(bool))
{
Expand Down Expand Up @@ -150,5 +150,5 @@ public bool Deserialize(ReadOnlySpan<byte> buffer)
{
return BitConverter.ToBoolean(buffer);
}
}
}
}

0 comments on commit 6de300f

Please sign in to comment.