diff mod_firewall/conditions.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 7ba6ed553c93
children 4161ff87e5a4
line wrap: on
line diff
--- a/mod_firewall/conditions.lib.lua	Thu Mar 10 19:00:04 2016 +0100
+++ b/mod_firewall/conditions.lib.lua	Fri Mar 11 18:13:53 2016 +0100
@@ -28,7 +28,7 @@
 		if pattern == "*" then
 			return part;
 		end
-		if pattern:match("^<.*>$") then
+		if pattern:find("^<.*>$") then
 			pattern = pattern:match("^<(.*)>$");
 		else
 			pattern = pattern:gsub("%p", "%%%0"):gsub("%%(%p)", wildcard_equivs);
@@ -144,7 +144,7 @@
 				op = "or";
 			end
 			table.insert(conditions, ("current_day >= %d %s current_day <= %d"):format(day_start_num, op, day_end_num));
-		elseif day_range:match("%a") then
+		elseif day_range:find("%a") then
 			local day = resolve_day_number(day_range:match("%a+"));
 			table.insert(conditions, "current_day == "..day);
 		else