diff options
| author | OpportunityLiu <[email protected]> | 2019-07-28 14:47:58 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-28 14:47:58 +0800 |
| commit | fb9a434ada47e47e543f62e353c7375f93f82c39 (patch) | |
| tree | b8cea2dafac812a44add3f7f88a1f39d064f1142 /xmake/core/base/serialize.lua | |
| parent | 7da50f74093bac43174a6ff236ccd72680a5ec81 (diff) | |
use cache for keywords
Diffstat (limited to 'xmake/core/base/serialize.lua')
| -rw-r--r-- | xmake/core/base/serialize.lua | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/xmake/core/base/serialize.lua b/xmake/core/base/serialize.lua index 16159bb93..de80350cd 100644 --- a/xmake/core/base/serialize.lua +++ b/xmake/core/base/serialize.lua @@ -30,7 +30,14 @@ local table = require("base/table") local hashset = require("base/hashset") -- reserved keywords in lua -local keywords = hashset.of("and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while") +function serialize._keywords() + local keywords = serialize._KEYWORDS + if not keywords then + keywords = hashset.of("and", "break", "do", "else", "elseif", "end", "false", "for", "function", "goto", "if", "in", "local", "nil", "not", "or", "repeat", "return", "then", "true", "until", "while") + serialize._KEYWORDS = keywords + end + return keywords +end -- save original interfaces serialize._dump = serialize._dump or string._dump or string.dump @@ -113,6 +120,7 @@ function serialize._maketable(object, opt, level, path, reftab) local dformat = opt.indentstr and "%s = %s" or "%s=%s" local sformat = opt.indentstr and "[%q] = %s" or "[%q]=%s" local nformat = opt.indentstr and "[%s] = %s" or "[%s]=%s" + local keywords = serialize._keywords() for k, v in pairs(serialized) do local format -- serialize key |
