Skip to content

Commit 0db2eb6

Browse files
refactor
Based on Emma's suggestion, removing the `SizeOfLengthField` method and `TryBeginReadInternal` check within the ReadValueSafe (string) method and replacing that with `ReadLengthSafe`.
1 parent b645ff3 commit 0db2eb6

1 file changed

Lines changed: 1 addition & 10 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Serialization/FastBufferReader.cs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -654,13 +654,7 @@ public unsafe void ReadValueSafe(out string s, bool oneByteChars = false)
654654
}
655655
#endif
656656

657-
if (!TryBeginReadInternal(SizeOfLengthField()))
658-
{
659-
throw new OverflowException("Reading past the end of the buffer");
660-
}
661-
662-
663-
ReadLength(out int length);
657+
ReadLengthSafe(out int length);
664658

665659
// Validate the string's byte count based on the character count and if it is valid begin reading based on the returned
666660
// byte count.
@@ -673,9 +667,6 @@ public unsafe void ReadValueSafe(out string s, bool oneByteChars = false)
673667
ReadString(out s, length, oneByteChars);
674668
}
675669

676-
[MethodImpl(MethodImplOptions.AggressiveInlining)]
677-
private static int SizeOfLengthField() => sizeof(uint);
678-
679670
[MethodImpl(MethodImplOptions.AggressiveInlining)]
680671
private void ReadLengthSafe(out uint length) => ReadUnmanagedSafe(out length);
681672

0 commit comments

Comments
 (0)