Skip to content
Snippets Groups Projects
Commit 6dd544c5 authored by Jan Tattermusch's avatar Jan Tattermusch
Browse files

tiny optimization in MetadataArraySafeHandle

parent 37f3184b
No related branches found
No related tags found
No related merge requests found
...@@ -50,6 +50,11 @@ namespace Grpc.Core.Internal ...@@ -50,6 +50,11 @@ namespace Grpc.Core.Internal
{ {
using (Profilers.ForCurrentThread().NewScope("MetadataArraySafeHandle.Create")) using (Profilers.ForCurrentThread().NewScope("MetadataArraySafeHandle.Create"))
{ {
if (metadata.Count == 0)
{
return new MetadataArraySafeHandle();
}
// TODO(jtattermusch): we might wanna check that the metadata is readonly // TODO(jtattermusch): we might wanna check that the metadata is readonly
var metadataArray = Native.grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count)); var metadataArray = Native.grpcsharp_metadata_array_create(new UIntPtr((ulong)metadata.Count));
for (int i = 0; i < metadata.Count; i++) for (int i = 0; i < metadata.Count; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment