Skip to content

Commit ee434cd

Browse files
committed
Avoid formatter lookup for empty array
Also revert a change made in this PR that is irrelevant and not consistent with typical style.
1 parent 9b64cb5 commit ee434cd

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/CollectionFormatter.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -793,14 +793,14 @@ public IList Deserialize(ref MessagePackReader reader, MessagePackSerializerOpti
793793
return default(IList);
794794
}
795795

796-
IMessagePackFormatter<object> formatter = options.Resolver.GetFormatterWithVerify<object>();
797-
798796
var count = reader.ReadArrayHeader();
799797
if (count == 0)
800798
{
801799
return Array.Empty<object>();
802800
}
803801

802+
IMessagePackFormatter<object> formatter = options.Resolver.GetFormatterWithVerify<object>();
803+
804804
var list = new object[count];
805805
options.Security.DepthStep(ref reader);
806806
try

src/MessagePack.UnityClient/Assets/Scripts/MessagePack/Formatters/DateTimeFormatters.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public DateTime[] Deserialize(ref MessagePackReader reader, MessagePackSerialize
5151
{
5252
if (reader.TryReadNil())
5353
{
54-
return default;
54+
return null;
5555
}
5656

5757
var len = reader.ReadArrayHeader();

0 commit comments

Comments
 (0)