Quantcast

Minor optimization: release nodes in O(n) time, not O(n^2) time.

Johnny C. Lam [04-18-13 - 23:43]
Minor optimization: release nodes in O(n) time, not O(n^2) time.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@904 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCompile.lua
diff --git a/OvaleCompile.lua b/OvaleCompile.lua
index 8455c48..a3c90f0 100644
--- a/OvaleCompile.lua
+++ b/OvaleCompile.lua
@@ -33,7 +33,6 @@ local strlower = string.lower
 local strmatch = string.match
 local strsub = string.sub
 local tinsert = table.insert
-local tremove = table.remove
 local wipe = table.wipe
 local API_GetItemInfo = GetItemInfo
 local API_GetSpellInfo = GetSpellInfo
@@ -715,10 +714,8 @@ local function CompileScript(text)
 	wipe(self_functionCalls)

 	-- Return all existing nodes to the node pool.
-	local node
-	while true do
-		node = tremove(self_node)
-		if not node then break end
+	for i, node in pairs(self_node) do
+		self_node[i] = nil
 		self_pool:Release(node)
 	end
 	wipe(self_node)