summaryrefslogtreecommitdiff
path: root/xmake/core/base/serialize.lua
diff options
context:
space:
mode:
authorOpportunityLiu <[email protected]>2019-07-28 14:47:58 +0800
committerOpportunityLiu <[email protected]>2019-07-28 14:47:58 +0800
commitfb9a434ada47e47e543f62e353c7375f93f82c39 (patch)
treeb8cea2dafac812a44add3f7f88a1f39d064f1142 /xmake/core/base/serialize.lua
parent7da50f74093bac43174a6ff236ccd72680a5ec81 (diff)
use cache for keywords
Diffstat (limited to 'xmake/core/base/serialize.lua')
-rw-r--r--xmake/core/base/serialize.lua10
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