mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
Make RobustMappedStringSerializer use NetSerializer's string serialization code again.
It's much more efficient, especially after more optimizations I just made to it.
This commit is contained in:
@@ -1178,10 +1178,8 @@ namespace Robust.Shared.Serialization
|
||||
|
||||
// indicate not mapped
|
||||
WriteCompressedUnsignedInt(stream, UnmappedString);
|
||||
var buf = Encoding.UTF8.GetBytes(value);
|
||||
//Logger.DebugS("szr", $"Encoded unmapped string: {value}");
|
||||
WriteCompressedUnsignedInt(stream, (uint) buf.Length);
|
||||
stream.Write(buf);
|
||||
|
||||
Primitives.WritePrimitive(stream, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1224,13 +1222,7 @@ namespace Robust.Shared.Serialization
|
||||
if (mapIndex == UnmappedString)
|
||||
{
|
||||
// not mapped
|
||||
var length = checked((int)ReadCompressedUnsignedInt(stream, out _));
|
||||
// ReSharper disable once SuggestVarOrType_Elsewhere
|
||||
Span<byte> buf = stackalloc byte[length];
|
||||
stream.Read(buf);
|
||||
value = Encoding.UTF8.GetString(buf);
|
||||
//Logger.DebugS("szr", $"Decoded unmapped string: {value}");
|
||||
|
||||
Primitives.ReadPrimitive(stream, out value);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user