albertodemichelis / squirrel

Official repository for the programming language Squirrel
http://www.squirrel-lang.org
MIT License
913 stars 156 forks source link

Fix creating unnecessary temporary object with refcount #228

Closed VasiliyRyabtsev closed 3 years ago

VasiliyRyabtsev commented 3 years ago

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 an SQObject and because HashObj() accepted SQObjectPtr&, a temporary SQObjectPtr was created and refcounting was performed, which only lead to unnecessary overhead.

albertodemichelis commented 3 years ago

good catch, thank you.