From 207b4ddf4d39c596dfbee4dc3fc71b64f8952e50 Mon Sep 17 00:00:00 2001 From: Max Cahill Date: Fri, 1 Nov 2024 11:27:27 +1100 Subject: [PATCH] slightly refactored make_pooled --- make_pooled.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/make_pooled.lua b/make_pooled.lua index bc99386..120221c 100644 --- a/make_pooled.lua +++ b/make_pooled.lua @@ -30,10 +30,10 @@ return function(class, limit) --get a pooled object --(re-initialised with new, or freshly constructed if the pool was empty) function class:pooled(...) - if #_pool == 0 then + local instance = class:drain_pool() + if not instance then return class(...) end - local instance = class:drain_pool() instance:new(...) return instance end