mirror of
https://github.com/1bardesign/batteries.git
synced 2024-11-22 06:04:35 +00:00
slightly refactored make_pooled
This commit is contained in:
parent
bde95f208f
commit
207b4ddf4d
@ -30,10 +30,10 @@ return function(class, limit)
|
|||||||
--get a pooled object
|
--get a pooled object
|
||||||
--(re-initialised with new, or freshly constructed if the pool was empty)
|
--(re-initialised with new, or freshly constructed if the pool was empty)
|
||||||
function class:pooled(...)
|
function class:pooled(...)
|
||||||
if #_pool == 0 then
|
local instance = class:drain_pool()
|
||||||
|
if not instance then
|
||||||
return class(...)
|
return class(...)
|
||||||
end
|
end
|
||||||
local instance = class:drain_pool()
|
|
||||||
instance:new(...)
|
instance:new(...)
|
||||||
return instance
|
return instance
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user