luyuhuang.github.io icon indicating copy to clipboard operation
luyuhuang.github.io copied to clipboard

序列化 Lua 对象 - Luyu Huang's Tech Blog

Open luyuhuang opened this issue 4 years ago • 0 comments

https://luyuhuang.github.io/2020/03/18/serialize-lua-objects.html

在项目中由于种种需求经常需要将对象序列化成一个字符串. 由于 Lua 唯一的复合结构是 table, 所以实现起来还是比较简单的. 之前我们的做法是用 Lua 写一个递归函数遍历 table 的键值然后转换成字符串并拼接起来. 然而 Lua 在字符串拼接的过程中会不断地构造字符串对象, 因此这样的实现方式性能较差...

luyuhuang avatar Mar 24 '20 14:03 luyuhuang