aboutsummaryrefslogtreecommitdiff
path: root/csharp/src/Google.Protobuf/FieldCodec.cs
diff options
context:
space:
mode:
authorJon Skeet <skeet@pobox.com>2016-07-09 07:16:06 +0100
committerGitHub <noreply@github.com>2016-07-09 07:16:06 +0100
commit8779cba302f330f478ce10c4e58a34e7b6360471 (patch)
tree9894d31379ffcb851ed705e476b164d668864097 /csharp/src/Google.Protobuf/FieldCodec.cs
parentc404c2a2e3e9a05096fc86f080b6d966b2b0043c (diff)
parent3df146e198705dee11de890577f004e42126cd70 (diff)
downloadprotobuf-8779cba302f330f478ce10c4e58a34e7b6360471.tar.gz
protobuf-8779cba302f330f478ce10c4e58a34e7b6360471.tar.bz2
protobuf-8779cba302f330f478ce10c4e58a34e7b6360471.zip
Merge pull request #1764 from jskeet/remove-is-value-type
Remove unnecessary reflection call
Diffstat (limited to 'csharp/src/Google.Protobuf/FieldCodec.cs')
-rw-r--r--csharp/src/Google.Protobuf/FieldCodec.cs3
1 files changed, 2 insertions, 1 deletions
diff --git a/csharp/src/Google.Protobuf/FieldCodec.cs b/csharp/src/Google.Protobuf/FieldCodec.cs
index 98313088..c28b47e1 100644
--- a/csharp/src/Google.Protobuf/FieldCodec.cs
+++ b/csharp/src/Google.Protobuf/FieldCodec.cs
@@ -347,7 +347,8 @@ namespace Google.Protobuf
public sealed class FieldCodec<T>
{
private static readonly T DefaultDefault;
- private static readonly bool TypeSupportsPacking = typeof(T).IsValueType() && Nullable.GetUnderlyingType(typeof(T)) == null;
+ // Only non-nullable value types support packing. This is the simplest way of detecting that.
+ private static readonly bool TypeSupportsPacking = default(T) != null;
static FieldCodec()
{