summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-06-20 23:10:12 +0800
committerruki <[email protected]>2020-06-20 23:10:12 +0800
commit558c97a962d596becf1ec1d7d9c88a6239e1627b (patch)
tree8cc30331d388538d912a11b83609dd6d447ed864
parent4db557bedf4839f2c09b5104a834e57b1d369071 (diff)
remove some ifelse
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/find_programver.lua10
-rw-r--r--xmake/core/sandbox/modules/string.lua2
2 files changed, 4 insertions, 8 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
index ae70b17a8..b51f6a8ba 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/find_programver.lua
@@ -65,7 +65,7 @@ function sandbox_lib_detect_find_programver.main(program, opt)
local cacheinfo = cache.load(cachekey)
local result = cacheinfo[program]
if result ~= nil and not opt.force then
- return utils.ifelse(result, result, nil)
+ return result and result or nil
end
-- attempt to get version output info
@@ -98,13 +98,9 @@ function sandbox_lib_detect_find_programver.main(program, opt)
end
end
- -- cache result
- cacheinfo[program] = utils.ifelse(result, result, false)
-
- -- save cache info
+ -- save result
+ cacheinfo[program] = result and result or false
cache.save(cachekey, cacheinfo)
-
- -- ok?
return result
end
diff --git a/xmake/core/sandbox/modules/string.lua b/xmake/core/sandbox/modules/string.lua
index 36f2f7b58..755b12fba 100644
--- a/xmake/core/sandbox/modules/string.lua
+++ b/xmake/core/sandbox/modules/string.lua
@@ -48,7 +48,7 @@ function sandbox_string.vformat(format, ...)
if #{...} > 0 then
-- escape "%$", "%(", "%)", "%%" to '$', '(', ')', '%%'
- format = format:gsub("%%([%$%(%)%%])", function (ch) return utils.ifelse(ch ~= "%", "%%" .. ch, "%%%%") end)
+ format = format:gsub("%%([%$%(%)%%])", function (ch) return ch ~= "%" and ("%%" .. ch) or "%%%%" end)
-- try to format it
result = string.format(format, ...)