diff 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
line wrap: on
line diff
--- a/mod_firewall/actions.lib.lua	Thu Mar 10 19:00:04 2016 +0100
+++ b/mod_firewall/actions.lib.lua	Fri Mar 11 18:13:53 2016 +0100
@@ -29,7 +29,7 @@
 				else
 					table.insert(attr_str, ", ");
 				end
-				if k:match("^%a%w*$") then
+				if k:find("^%a%w*$") then
 					table.insert(attr_str, string.format("%s = %q", k, v));
 				else
 					table.insert(attr_str, string.format("[%q] = %q", k, v));
@@ -45,7 +45,7 @@
 				code[#code+1] = (string.format(":tag(%q%s)", name, table.concat(attr_str)));
 			end
 		end
-		if text and text:match("%S") then
+		if text and text:find("%S") then
 			code[#code+1] = (string.format(":text(%q)", text));
 		elseif short_close then
 			short_close = nil;