mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 21:43:57 +00:00
C# performance optimization to Pad/Prep methods
This commit is contained in:
@@ -146,6 +146,13 @@ namespace FlatBuffers
|
|||||||
_buffer[offset] = value;
|
_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
|
// this method exists in order to conform with Java ByteBuffer standards
|
||||||
public void Put(int offset, byte value)
|
public void Put(int offset, byte value)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,10 +69,7 @@ namespace FlatBuffers
|
|||||||
|
|
||||||
public void Pad(int size)
|
public void Pad(int size)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < size; i++)
|
_bb.PutByte(_space -= size, 0, size);
|
||||||
{
|
|
||||||
_bb.PutByte(--_space, 0);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Doubles the size of the ByteBuffer, and copies the old data towards
|
// Doubles the size of the ByteBuffer, and copies the old data towards
|
||||||
@@ -116,7 +113,8 @@ namespace FlatBuffers
|
|||||||
_space += (int)_bb.Length - oldBufSize;
|
_space += (int)_bb.Length - oldBufSize;
|
||||||
|
|
||||||
}
|
}
|
||||||
Pad(alignSize);
|
if (alignSize > 0)
|
||||||
|
Pad(alignSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void PutBool(bool x)
|
public void PutBool(bool x)
|
||||||
|
|||||||
Reference in New Issue
Block a user