Skip to content
Snippets Groups Projects
Commit be11d2b6 authored by Oli Wilkinson's avatar Oli Wilkinson
Browse files

C# performance optimization to Pad/Prep methods

parent b8187e5b
No related branches found
No related tags found
No related merge requests found
......@@ -146,6 +146,13 @@ namespace FlatBuffers
_buffer[offset] = value;
}
public void PutByte(int offset, byte value, int count)
{
AssertOffsetAndLength(offset, sizeof(byte) * count);
for (var i = 0; i < count; ++i)
_buffer[offset + i] = value;
}
// this method exists in order to conform with Java ByteBuffer standards
public void Put(int offset, byte value)
{
......
......@@ -69,10 +69,7 @@ namespace FlatBuffers
public void Pad(int size)
{
for (var i = 0; i < size; i++)
{
_bb.PutByte(--_space, 0);
}
_bb.PutByte(_space -= size, 0, size);
}
// Doubles the size of the ByteBuffer, and copies the old data towards
......@@ -116,7 +113,8 @@ namespace FlatBuffers
_space += (int)_bb.Length - oldBufSize;
}
Pad(alignSize);
if (alignSize > 0)
Pad(alignSize);
}
public void PutBool(bool x)
......
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