NetworkWriter: runtime resizing comment

This commit is contained in:
vis2k 2022-02-16 15:50:51 +08:00
parent 2ea328750c
commit c3ac08203a

View File

@ -38,6 +38,9 @@ public void Reset()
Position = 0; Position = 0;
} }
// NOTE that our runtime resizing comes at no extra cost because:
// 1. 'has space' checks are necessary even for fixed sized writers.
// 2. all writers will eventually be large enough to stop resizing.
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
void EnsureCapacity(int value) void EnsureCapacity(int value)
{ {
@ -111,6 +114,9 @@ internal unsafe void WriteBlittable<T>(T value)
int size = sizeof(T); int size = sizeof(T);
// ensure capacity // ensure capacity
// NOTE that our runtime resizing comes at no extra cost because:
// 1. 'has space' checks are necessary even for fixed sized writers.
// 2. all writers will eventually be large enough to stop resizing.
EnsureCapacity(Position + size); EnsureCapacity(Position + size);
// write blittable // write blittable