From d9b42e4d18148b23b904a43cda4cad8abbf6ac84 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sun, 6 Apr 2014 18:45:17 +0000 Subject: [PATCH] Use string.sub instead of string.find where possible. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1260 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleBestAction.lua | 1 - OvaleCompile.lua | 11 +++++------ OvaleDamageTaken.lua | 7 ++++--- OvaleStance.lua | 1 - 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/OvaleBestAction.lua b/OvaleBestAction.lua index 040265b..294e622 100644 --- a/OvaleBestAction.lua +++ b/OvaleBestAction.lua @@ -33,7 +33,6 @@ local floor = math.floor local ipairs = ipairs local loadstring = loadstring local pairs = pairs -local strfind = string.find local tonumber = tonumber local tostring = tostring local wipe = table.wipe diff --git a/OvaleCompile.lua b/OvaleCompile.lua index 5706ddc..ed418af 100644 --- a/OvaleCompile.lua +++ b/OvaleCompile.lua @@ -31,7 +31,6 @@ local OvaleStance = nil local ipairs = ipairs local pairs = pairs local tonumber = tonumber -local strfind = string.find local strgmatch = string.gmatch local strgsub = string.gsub local strlen = string.len @@ -210,7 +209,7 @@ local function ParseFunction(prefix, func, params) end if not paramList.target then - if strfind(func, "Target") == 1 then + if strsub(func, 1, 6) == "Target" then paramList.target = "target" func = strsub(func, 7) end @@ -225,13 +224,13 @@ local function ParseFunction(prefix, func, params) -- "debuff" and "buff" conditions implicitly set their aura filter. if not paramList.filter then - if strfind(func, "debuff") == 1 then + if strsub(func, 1, 6) == "debuff" then paramList.filter = "debuff" - elseif strfind(func, "buff") == 1 then + elseif strsub(func, 1, 4) == "buff" then paramList.filter = "buff" - elseif strfind(func, "otherdebuff") == 1 then + elseif strsub(func, 1, 11) == "otherdebuff" then paramList.filter = "debuff" - elseif strfind(func, "otherbuff") == 1 then + elseif strsub(func, 1, 9) == "otherbuff" then paramList.filter = "buff" end end diff --git a/OvaleDamageTaken.lua b/OvaleDamageTaken.lua index 7854ba9..89c3bea 100644 --- a/OvaleDamageTaken.lua +++ b/OvaleDamageTaken.lua @@ -59,13 +59,14 @@ end function OvaleDamageTaken:COMBAT_LOG_EVENT_UNFILTERED(event, timestamp, cleuEvent, hideCaster, sourceGUID, sourceName, sourceFlags, sourceRaidFlags, destGUID, destName, destFlags, destRaidFlags, ...) local arg12, arg13, arg14, arg15, arg16, arg17, arg18, arg19, arg20, arg21, arg22, arg23 = ... - if destGUID == self_guid and cleuEvent:find("_DAMAGE") then + if destGUID == self_guid and strsub(cleuEvent, -7) == "_DAMAGE" then local now = API_GetTime() - if cleuEvent:find("SWING_") == 1 then + local eventPrefix = strsub(cleuEvent, 1, 6) + if eventPrefix == "SWING_" then local amount = arg12 Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s caused %d damage.", cleuEvent, amount) self:AddDamageTaken(now, amount) - elseif cleuEvent:find("RANGE_") == 1 or cleuEvent:find("SPELL_") == 1 then + elseif eventPrefix == "RANGE_" or eventPrefix == "SPELL_" then local spellName, amount = arg13, arg15 Ovale:DebugPrintf(OVALE_DAMAGE_TAKEN_DEBUG, "%s (%s) caused %d damage.", cleuEvent, spellName, amount) self:AddDamageTaken(now, amount) diff --git a/OvaleStance.lua b/OvaleStance.lua index 9627fd2..b040ae3 100644 --- a/OvaleStance.lua +++ b/OvaleStance.lua @@ -16,7 +16,6 @@ Ovale.OvaleStance = OvaleStance -- local ipairs = ipairs local pairs = pairs -local strfind = string.find local tinsert = table.insert local tsort = table.sort local wipe = table.wipe -- 1.7.9.5