Browse Source

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.
VasiliyRyabtsev 5 years ago
parent
commit
b4f600ebc0
1 changed files with 1 additions and 1 deletions
  1. 1 1
      squirrel/sqtable.h

+ 1 - 1
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;