diff options
author | Marius <mariausol@gmail.com> | 2010-10-29 13:00:23 +0300 |
---|---|---|
committer | Marius <mariausol@gmail.com> | 2010-10-29 13:00:23 +0300 |
commit | 42c4d16ce1daa37425d12be6c87d6f64a72b5094 (patch) | |
tree | 494b8c10ccef29abe26db9acf08261ce78c16cf6 /tex/context/base/lxml-xml.lua | |
parent | f56f0054360a9bdfb57de9abcf0d81a2766c22b9 (diff) | |
download | context-42c4d16ce1daa37425d12be6c87d6f64a72b5094.tar.gz |
beta 2010.10.29 11:35
Diffstat (limited to 'tex/context/base/lxml-xml.lua')
-rw-r--r-- | tex/context/base/lxml-xml.lua | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/tex/context/base/lxml-xml.lua b/tex/context/base/lxml-xml.lua index 2a6d56800..2053d2353 100644 --- a/tex/context/base/lxml-xml.lua +++ b/tex/context/base/lxml-xml.lua @@ -26,15 +26,18 @@ local function all(collected) return collected end -local function reverse(collected) - if collected then - local reversed = { } - for c=#collected,1,-1 do - reversed[#reversed+1] = collected[c] - end - return reversed - end -end +--~ local function reverse(collected) +--~ if collected then +--~ local reversed, r = { }, 0 +--~ for c=#collected,1,-1 do +--~ r = r + 1 +--~ reversed[r] = collected[c] +--~ end +--~ return reversed +--~ end +--~ end + +local reverse = table.reversed local function attribute(collected,name) if collected and #collected > 0 then @@ -125,11 +128,12 @@ end local function texts(collected) if collected then - local t = { } + local t, n = { }, 0 for c=1,#collected do local e = collection[c] if e and e.dt then - t[#t+1] = e.dt + n = n + 1 + t[n] = e.dt end end return t @@ -172,14 +176,15 @@ end local function tags(collected,nonamespace) if collected then - local t = { } + local t, n = { }, 0 for c=1,#collected do local e = collected[c] local ns, tg = e.ns, e.tg + n = n + 1 if nonamespace or ns == "" then - t[#t+1] = tg + t[n] = tg else - t[#t+1] = ns .. ":" .. tg + t[n] = ns .. ":" .. tg end end return t |