comparison mod_firewall/actions.lib.lua @ 2070:2356114ff505

mod_firewall: Optimize string match operations, string.find is faster than .match since no string is returned
author Kim Alvefur <zash@zash.se>
date Fri, 11 Mar 2016 18:13:53 +0100
parents 7dbde05b48a9
children de6b95d5e01b
comparison
equal deleted inserted replaced
2069:cf9cd666ba00 2070:2356114ff505
27 if #attr_str == 0 then 27 if #attr_str == 0 then
28 table.insert(attr_str, ", { "); 28 table.insert(attr_str, ", { ");
29 else 29 else
30 table.insert(attr_str, ", "); 30 table.insert(attr_str, ", ");
31 end 31 end
32 if k:match("^%a%w*$") then 32 if k:find("^%a%w*$") then
33 table.insert(attr_str, string.format("%s = %q", k, v)); 33 table.insert(attr_str, string.format("%s = %q", k, v));
34 else 34 else
35 table.insert(attr_str, string.format("[%q] = %q", k, v)); 35 table.insert(attr_str, string.format("[%q] = %q", k, v));
36 end 36 end
37 end 37 end
43 first = nil; 43 first = nil;
44 else 44 else
45 code[#code+1] = (string.format(":tag(%q%s)", name, table.concat(attr_str))); 45 code[#code+1] = (string.format(":tag(%q%s)", name, table.concat(attr_str)));
46 end 46 end
47 end 47 end
48 if text and text:match("%S") then 48 if text and text:find("%S") then
49 code[#code+1] = (string.format(":text(%q)", text)); 49 code[#code+1] = (string.format(":text(%q)", text));
50 elseif short_close then 50 elseif short_close then
51 short_close = nil; 51 short_close = nil;
52 code[#code+1] = (":up()"); 52 code[#code+1] = (":up()");
53 end 53 end