Software /
code /
prosody-modules
Comparison
mod_mam/rsm.lib.lua @ 1401:1a5ae0dee157
mod_mam/rsm.lib: Pointless optimization
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 30 Apr 2014 13:19:15 +0200 |
parent | 1102:bfde5e5318d7 |
child | 1402:57ee26681561 |
comparison
equal
deleted
inserted
replaced
1400:ce5e397a7768 | 1401:1a5ae0dee157 |
---|---|
3 local type = type; | 3 local type = type; |
4 local pairs = pairs; | 4 local pairs = pairs; |
5 | 5 |
6 local xmlns_rsm = 'http://jabber.org/protocol/rsm'; | 6 local xmlns_rsm = 'http://jabber.org/protocol/rsm'; |
7 | 7 |
8 local element_parsers; | 8 local element_parsers = {}; |
9 | 9 |
10 do | 10 do |
11 local parsers = element_parsers; | |
11 local function xs_int(st) | 12 local function xs_int(st) |
12 return tonumber((st:get_text())); | 13 return tonumber((st:get_text())); |
13 end | 14 end |
14 local function xs_string(st) | 15 local function xs_string(st) |
15 return st:get_text(); | 16 return st:get_text(); |
16 end | 17 end |
17 | 18 |
18 element_parsers = { | 19 parsers.after = xs_string; |
19 after = xs_string; | 20 parsers.before = function(st) |
20 before = function(st) | |
21 local text = st:get_text(); | 21 local text = st:get_text(); |
22 return text == "" or text; | 22 return text == "" or text; |
23 end; | 23 end; |
24 max = xs_int; | 24 parsers.max = xs_int; |
25 index = xs_int; | 25 parsers.index = xs_int; |
26 | 26 |
27 first = function(st) | 27 parsers.first = function(st) |
28 return { index = tonumber(st.attr.index); st:get_text() }; | 28 return { index = tonumber(st.attr.index); st:get_text() }; |
29 end; | 29 end; |
30 last = xs_string; | 30 parsers.last = xs_string; |
31 count = xs_int; | 31 parsers.count = xs_int; |
32 } | |
33 end | 32 end |
34 | 33 |
35 local element_generators = setmetatable({ | 34 local element_generators = setmetatable({ |
36 first = function(st, data) | 35 first = function(st, data) |
37 if type(data) == "table" then | 36 if type(data) == "table" then |