summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2015-11-26 13:31:42 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2015-11-26 13:31:42 +0000
commit5f3479a49388847ecd3ff0be8aea8fa276311e61 (patch)
tree06c1f6856479940cd90e834b7a7f6e399df08555
parent0cde41427841ad6f031175e9312f536837e40d35 (diff)
downloadlace-5f3479a49388847ecd3ff0be8aea8fa276311e61.tar.gz
lace.builtin: move any/allof function out
This is mostly for symmetry with the rest of the code, which has a separate _do_foo() most of the time. There may be minor performance improvements from not making closures as well, but that wasn't the purpose.
-rw-r--r--lib/lace/builtin.lua20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/lace/builtin.lua b/lib/lace/builtin.lua
index b0c7ad1..b76295c 100644
--- a/lib/lace/builtin.lua
+++ b/lib/lace/builtin.lua
@@ -204,6 +204,16 @@ end
--[ Control types ]--------------------------------------------------
+local function _do_any_all_of(...)
+ local pass, msg = run_conditions(...)
+ if pass == nil then
+ -- Offset error location by anyof/allof word
+ err.offset(msg, 1)
+ return nil, msg
+ end
+ return pass, msg
+end
+
local function _compile_any_all_of(compcontext, mtype, first, second, ...)
if type(first) ~= "string" then
return err.error("Expected at least two names, got none", {1})
@@ -213,15 +223,7 @@ local function _compile_any_all_of(compcontext, mtype, first, second, ...)
end
return {
- fn = (function(exec_context, cond, anyof)
- local pass, msg = run_conditions(exec_context, cond, anyof)
- if pass == nil then
- -- Offset error location by anyof/allof word
- err.offset(msg, 1)
- return nil, msg
- end
- return pass, msg
- end),
+ fn = _do_any_all_of,
args = { { first, second, ...}, mtype == "anyof" }
}
end