Use cache on barekey in ITomlSerializedObject<T>.Serialize

Merged
PR
4mo ago
+695-63

This PR improves generated serialization of barekey (A-Za-z0-9_-) in ITomlSerializedObject<T>.Serialize.

Changed:

  • If key is barekey, the implementation changes from Utf8TomlDocumentWriter.PushKey to Utf8TomlDocumentWriter.PushBareKey, which skips some verification process. And when calling Utf8TomlDocumentWriter.PushBareKey, it uses a cached key (ImmutableArray<byte>) instead of a ReadOnlySpan<byte> .
  • If table header key is barekey, the implementation changes from Utf8TomlDocumentWriter.WriteTableHeader to Utf8TomlDocumentWriter.WriteBareTableHeader, which skips some verification process.