浏览代码

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 年之前
父节点
当前提交
b4f600ebc0
共有 1 个文件被更改,包括 1 次插入1 次删除
  1. 1 1
      squirrel/sqtable.h

+ 1 - 1
squirrel/sqtable.h

@@ -12,7 +12,7 @@
 
 
 #define hashptr(p)  ((SQHash)(((SQInteger)p) >> 3))
 #define hashptr(p)  ((SQHash)(((SQInteger)p) >> 3))
 
 
-inline SQHash HashObj(const SQObjectPtr &key)
+inline SQHash HashObj(const SQObject &key)
 {
 {
     switch(sq_type(key)) {
     switch(sq_type(key)) {
         case OT_STRING:     return _string(key)->_hash;
         case OT_STRING:     return _string(key)->_hash;