From b4f600ebc04ba1ebbc2bad0b3dfb5f18d5b11686 Mon Sep 17 00:00:00 2001 From: VasiliyRyabtsev Date: Thu, 29 Oct 2020 00:22:00 +0300 Subject: [PATCH] Fix creating unnecessary temporary object with refcount Using the SQObject& is enough for HashObj() function. In the following code RefTable::RefNode *RefTable::Get(SQObject &obj,SQHash &mainpos,RefNode **prev,bool add) { RefNode *ref; mainpos = ::HashObj(obj)&(_numofslots-1); obj was SQObject and because HashObj() accepted SQObjectPtr&, a temporary SQObjectPtr was created and refcounting was performed, which only lead to unnecessary overhead. --- squirrel/sqtable.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/squirrel/sqtable.h b/squirrel/sqtable.h index 59db331..8ca3ae7 100644 --- a/squirrel/sqtable.h +++ b/squirrel/sqtable.h @@ -12,7 +12,7 @@ #define hashptr(p) ((SQHash)(((SQInteger)p) >> 3)) -inline SQHash HashObj(const SQObjectPtr &key) +inline SQHash HashObj(const SQObject &key) { switch(sq_type(key)) { case OT_STRING: return _string(key)->_hash;