projects
/
prosody.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
util.stanza: Optimisation, remove useless if...then in stanza:children() iterator
[prosody.git]
/
util
/
iterators.lua
diff --git
a/util/iterators.lua
b/util/iterators.lua
index ba33bc80b1e5ebb417dc6513ff5eaa9317a46390..cc50482721b485b5ecce731c820813b0ad203284 100644
(file)
--- a/
util/iterators.lua
+++ b/
util/iterators.lua
@@
-1,6
+1,6
@@
-- Prosody IM
-- Prosody IM
--- Copyright (C) 2008-20
09
Matthew Wild
--- Copyright (C) 2008-20
09
Waqas Hussain
+-- Copyright (C) 2008-20
10
Matthew Wild
+-- Copyright (C) 2008-20
10
Waqas Hussain
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
-- This project is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
@@
-90,6
+90,15
@@
function head(n, f, s, var)
end, s;
end
end, s;
end
+-- Skip the first n items an iterator returns
+function skip(n, f, s, var)
+ for i=1,n do
+ var = f(s, var);
+ end
+ return f, s, var;
+end
+
+-- Return the last n items an iterator returns
function tail(n, f, s, var)
local results, count = {}, 0;
while true do
function tail(n, f, s, var)
local results, count = {}, 0;
while true do