You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on May 16, 2022. It is now read-only.
Escaping string character is hurt of performance of JSON serialization.
It is possible to reduce escape cost by creating custom UTF8 Encoding that includes JSON encoding/decoding.
for invoke internal FastAllocateString, it is necessary to inherit Encoding.
publicclassJsonUtf8Encoding:Encoding{
#region decode(for reader)
// (Encoding.GetString) -> GetCharCount -> (FastAllocateString) -> GetCharspublicoverrideintGetCharCount(byte[]bytes,intindex,intcount){// return CharCount is \" (.+) \", (.+) group unescaped.if(bytes[index]!='\"')thrownewInvalidOperationException();thrownewNotImplementedException();}publicoverrideintGetChars(byte[]bytes,intbyteIndex,intbyteCount,char[]chars,intcharIndex){thrownewNotImplementedException();}
#endregion
#region encode(for writer)
// should use GetByteCount? too large?publicoverrideintGetMaxByteCount(intcharCount){returnEncoding.UTF8.GetMaxByteCount(charCount)*2;// worst case, escaped.}publicoverrideunsafeintGetBytes(strings,intcharIndex,intcharCount,byte[]bytes,intbyteIndex){intbyteCount=bytes.Length-byteIndex;
fixed (char*pChars=s)
fixed (byte*pBytes=bytes){returnGetBytes(pChars+charIndex,charCount,pBytes+byteIndex,byteCount);}}publicoverrideunsafeintGetBytes(char*chars,intcharCount,byte*bytes,intbyteCount){thrownewNotImplementedException();}
#endregion
publicoverrideintGetBytes(char[]chars,intcharIndex,intcharCount,byte[]bytes,intbyteIndex){thrownewNotSupportedException();}publicoverrideintGetByteCount(char[]chars,intindex,intcount){thrownewNotSupportedException();}publicoverrideintGetMaxCharCount(intbyteCount){thrownewNotSupportedException();}}
Also, it is necessary to implement efficient UTF 8 encoding/decoding.
I found this article. http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
If there are any other good examples, please let me know.
The text was updated successfully, but these errors were encountered:
Escaping string character is hurt of performance of JSON serialization.
It is possible to reduce escape cost by creating custom UTF8 Encoding that includes JSON encoding/decoding.
for invoke internal
FastAllocateString
, it is necessary to inherit Encoding.Also, it is necessary to implement efficient UTF 8 encoding/decoding.
I found this article.
http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
If there are any other good examples, please let me know.
The text was updated successfully, but these errors were encountered: