7

有趣的阅读 - ZString, 用于.NETCore和Unity的零分配StringBuilder

 3 years ago
source link: https://zhuanlan.zhihu.com/p/157678593
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

有趣的阅读 - ZString, 用于.NETCore和Unity的零分配StringBuilder

计算机图形学话题下的优秀回答者

本文作者Yoshifumi Kawai是ZString库的作者,在.NET Core 或Unity中使用该库可以在生成字符串时大大的减少内存的分配。(ZString的地址见本文结尾。)

v2-43afcea200764efa2bc4d995666251cb_720w.jpg

本文除了介绍 ZString 之外,作者还深入分析并解释了C#字符串,并解释了String的复杂性、常见的陷阱以及 ZString 库的必要性。除了ZString,Yoshifumi同样是MessagePack for C# 和 Utf8Json的作者。

全文分为以下几个部分:

  • String type configuration and generation
  • + concatenation and String.Concat
  • StringBuilder and SpanFormatter
  • Format and ReadOnlySpan<char>
  • Direct writing without allocate String
  • Utf8String and ‘ReadOnlySpan<byte>’

因此,无论是需要了解并采用ZString库作为自己的解决方案,还是想要了解C#的Stirng机制,本文都是一篇很好的阅读材料。

ZString Github:

ZString — Zero Allocation StringBuilder for .NET Core and Unity.

文章链接:

https://medium.com/@neuecc/zstring-zero-allocation-stringbuilder-for-net-core-and-unity-f3163c88c887​medium.com

http://weixin.qq.com/r/1kORidTELIlTrZDq9xbE (二维码自动识别)

v2-c46eaeb7ecbeda51ed0f1ad0f28e42fb_b.jpg



About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK