Small optimization
authorMikael Berthe <mikael@lilotux.net>
Tue, 13 Apr 2010 22:45:12 +0200
changeset 7 c515e8218c87
parent 6 7cf014d0d206
child 8 db84d97cf13d
Small optimization
mcbot/cmds/mcabber_bts.lua
mcbot/cmds/xep.lua
--- a/mcbot/cmds/mcabber_bts.lua	Tue Apr 13 22:43:43 2010 +0200
+++ b/mcbot/cmds/mcabber_bts.lua	Tue Apr 13 22:45:12 2010 +0200
@@ -18,10 +18,8 @@
 
 local function mcabber_bts (num)
     -- Check that xepnum is a valid number
-    if num then
-        num = num:gsub("[%s%?%.%!]+$", "")
-        num = tonumber(num)
-    end
+    if num then num = num:gsub("[%s%?%.%!]+$", "") end
+    num = tonumber(num)
     if not num or num < 1 then
         return nil, "Please provide an issue number"
     end
--- a/mcbot/cmds/xep.lua	Tue Apr 13 22:43:43 2010 +0200
+++ b/mcbot/cmds/xep.lua	Tue Apr 13 22:45:12 2010 +0200
@@ -33,7 +33,7 @@
 
 -- Logics comes from MattJ's riddim bot
 local function lookup_xep (xepnum)
-    xepnum = xepnum:gsub("[%s%?%.%!]+$", "")
+    if (xepnum) then xepnum = xepnum:gsub("[%s%?%.%!]+$", "") end
     -- Check that xepnum is a valid number
     xepnum = tonumber(xepnum)
     if not xepnum or xepnum <= 0 or xepnum > 9999 then return nil, "What XEP?" end