comparison mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 1741:07ceaf5f6f0d

mod_storage_xmlarchive: Optimize access to variables used in inner loop
author Kim Alvefur <zash@zash.se>
date Mon, 18 May 2015 02:45:49 +0200
parents 11f7fb2f927f
children ec50cecc9318
comparison
equal deleted inserted replaced
1740:11f7fb2f927f 1741:07ceaf5f6f0d
127 module:log("error", "Error: %s", ferr); 127 module:log("error", "Error: %s", ferr);
128 return; 128 return;
129 end 129 end
130 end 130 end
131 131
132 local q_with, q_start, q_end = query.with, query.start, query["end"];
132 for i = first_item, last_item, step do 133 for i = first_item, last_item, step do
133 local item = items[i]; 134 local item = items[i];
135 local i_when, i_with = item.when, item.with;
134 if not item then 136 if not item then
135 module:log("warn", "data[%q][%d] is nil", dates[d], i); 137 module:log("warn", "data[%q][%d] is nil", dates[d], i);
136 break; 138 break;
137 end 139 end
138 if xmlfile and in_range 140 if xmlfile and in_range
139 and (not query.with or item.with == query.with) 141 and (not q_with or i_with == q_with)
140 and (not query.start or item.when >= query.start) 142 and (not q_start or i_when >= q_start)
141 and (not query["end"] or item.when <= query["end"]) then 143 and (not q_end or i_when <= q_end) then
142 count = count + 1; 144 count = count + 1;
143 first_item = i + step; 145 first_item = i + step;
144 146
145 xmlfile:seek("set", item.offset); 147 xmlfile:seek("set", item.offset);
146 local data = xmlfile:read(item.length); 148 local data = xmlfile:read(item.length);