Interns strings for aliases, etc... for when content is deserialized from the contentNu table so we aren't duplicating strings when cold booting.

This commit is contained in:
Shannon
2020-07-03 00:26:55 +10:00
parent d2042e28e1
commit e75c9d2273
11 changed files with 193 additions and 10 deletions

View File

@@ -23,13 +23,15 @@ namespace Umbraco.Web.PublishedCache.NuCache.DataSource
return read(stream);
}
protected string ReadStringObject(Stream stream) // required 'cos string is not a struct
protected string ReadStringObject(Stream stream, bool intern = false) // required 'cos string is not a struct
{
var type = PrimitiveSerializer.Char.ReadFrom(stream);
if (type == 'N') return null;
if (type != 'S')
throw new NotSupportedException($"Cannot deserialize type '{type}', expected 'S'.");
return PrimitiveSerializer.String.ReadFrom(stream);
return intern
? string.Intern(PrimitiveSerializer.String.ReadFrom(stream))
: PrimitiveSerializer.String.ReadFrom(stream);
}
protected int? ReadIntObject(Stream stream) => ReadObject(stream, 'I', ReadInt);