use BinaryPrimitives.WriteUInt64LittleEndian

pull/7658/head
Jan Tattermusch 5 years ago
parent 1cf4df00cf
commit 45c8850389
  1. 14
      csharp/src/Google.Protobuf/WritingPrimitives.cs

@ -384,18 +384,8 @@ namespace Google.Protobuf
} }
else else
{ {
// TODO(jtattermusch): According to the benchmarks, writing byte-by-byte is actually faster BinaryPrimitives.WriteUInt64LittleEndian(buffer.Slice(state.position), value);
// than using BinaryPrimitives.WriteUInt64LittleEndian. state.position += length;
// This is strange especially because WriteUInt32LittleEndian seems to be much faster
// in terms of throughput.
buffer[state.position++] = ((byte)value);
buffer[state.position++] = ((byte)(value >> 8));
buffer[state.position++] = ((byte)(value >> 16));
buffer[state.position++] = ((byte)(value >> 24));
buffer[state.position++] = ((byte)(value >> 32));
buffer[state.position++] = ((byte)(value >> 40));
buffer[state.position++] = ((byte)(value >> 48));
buffer[state.position++] = ((byte)(value >> 56));
} }
} }

Loading…
Cancel
Save