Fix leaks to global namespace in OvalePool and OvalePoolGC.
Johnny C. Lam [10-23-13 - 07:18]
Fix leaks to global namespace in OvalePool and OvalePoolGC.
git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1089 d5049fe3-3747-40f7-a4b5-f36d6801af5f
diff --git a/OvalePool.lua b/OvalePool.lua
index e7222f6..e150157 100644
--- a/OvalePool.lua
+++ b/OvalePool.lua
@@ -16,6 +16,7 @@ Ovale.OvalePool = OvalePool
local assert = assert
local setmetatable = setmetatable
local tinsert = table.insert
+local tostring = tostring
local tremove = table.remove
local wipe = table.wipe
--</private-static-properties>
@@ -26,16 +27,16 @@ OvalePool.pool = nil
OvalePool.size = 0
OvalePool.unused = 0
OvalePool.__index = OvalePool
-do
- setmetatable(OvalePool, { __call = function(_, ...) return NewPool(...) end })
-end
--</public-static-properties>
--<private-static-methods>
-function NewPool(...)
- local obj = setmetatable({ name = ... }, OvalePool)
- obj:Reset()
- return obj
+do
+ local function NewPool(...)
+ local obj = setmetatable({ name = ... }, OvalePool)
+ obj:Reset()
+ return obj
+ end
+ setmetatable(OvalePool, { __call = function(_, ...) return NewPool(...) end })
end
--</private-static-methods>
@@ -77,6 +78,6 @@ function OvalePool:Reset()
end
function OvalePool:Debug()
- Ovale:FormatPrint("Pool %s has size %d with %d item(s).", self.name, self.size, self.unused)
+ Ovale:FormatPrint("Pool %s has size %d with %d item(s).", tostring(self.name), self.size, self.unused)
end
--</public-static-methods>
diff --git a/OvalePoolGC.lua b/OvalePoolGC.lua
index 7a1259b..a0ded75 100644
--- a/OvalePoolGC.lua
+++ b/OvalePoolGC.lua
@@ -14,6 +14,7 @@ Ovale.OvalePoolGC = OvalePoolGC
--<private-static-properties>
local setmetatable = setmetatable
+local tostring = tostring
--</private-static-properties>
--<public-static-properties>
@@ -22,17 +23,16 @@ OvalePoolGC.pool = nil
OvalePoolGC.size = 0
OvalePoolGC.unused = 0
OvalePoolGC.__index = OvalePoolGC
-do
- setmetatable(OvalePoolGC, { __call = function(_, ...) return NewPool(...) end })
-end
-
--</public-static-properties>
--<private-static-methods>
-function NewPool(...)
- local obj = setmetatable({ name = ... }, OvalePoolGC)
- obj:Reset()
- return obj
+do
+ local function NewPool(...)
+ local obj = setmetatable({ name = ... }, OvalePoolGC)
+ obj:Reset()
+ return obj
+ end
+ setmetatable(OvalePoolGC, { __call = function(_, ...) return NewPool(...) end })
end
--</private-static-methods>
@@ -53,6 +53,6 @@ function OvalePoolGC:Reset()
end
function OvalePoolGC:Debug()
- Ovale:FormatPrint("Pool %s has size %d.", self.name, self.size)
+ Ovale:FormatPrint("Pool %s has size %d.", tostring(self.name), self.size)
end
--</public-static-methods>