public T ReadInterned <T>(UnsafeReader stream, string internKey, CtxReadDelegate <T> readValueDelegate) { if (!InternRoots.TryGetValue(internKey, out var interningRoot)) { return(readValueDelegate(this, stream)); } var id = InternId.Read(stream); if (id.IsValid) { return(interningRoot.UnIntern <T>(id)); } return(readValueDelegate(this, stream)); }
public void WriteInterned <T>(UnsafeWriter stream, T value, string internKey, CtxWriteDelegate <T> writeValueDelegate) { if (!InternRoots.TryGetValue(internKey, out var interningRoot)) { writeValueDelegate(this, stream, value); return; } var id = interningRoot.Intern(value); InternId.Write(stream, id); if (!id.IsValid) { writeValueDelegate(this, stream, value); } }