aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-04 11:31:03 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2002-10-04 11:31:03 -0300
commit829befcc4198a98412757ad8bf4f67091564b515 (patch)
tree2f0915cb6a86cde0819a9c03025fc31ab476f3fb
parentd477e4ffd69dc530e3369015190db880de90aaf2 (diff)
downloadlua-829befcc4198a98412757ad8bf4f67091564b515.tar.gz
lua-829befcc4198a98412757ad8bf4f67091564b515.tar.bz2
lua-829befcc4198a98412757ad8bf4f67091564b515.zip
small optimization for object comparison
-rw-r--r--lobject.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/lobject.c b/lobject.c
index dd8bfe08..cdf49c92 100644
--- a/lobject.c
+++ b/lobject.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lobject.c,v 1.87 2002/09/02 19:54:49 roberto Exp roberto $ 2** $Id: lobject.c,v 1.88 2002/09/19 13:03:53 roberto Exp roberto $
3** Some generic functions over Lua objects 3** Some generic functions over Lua objects
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -57,7 +57,8 @@ int luaO_log2 (unsigned int x) {
57 57
58int luaO_rawequalObj (const TObject *t1, const TObject *t2) { 58int luaO_rawequalObj (const TObject *t1, const TObject *t2) {
59 if (ttype(t1) != ttype(t2)) return 0; 59 if (ttype(t1) != ttype(t2)) return 0;
60 switch (ttype(t1)) { 60 if (iscollectable(t1)) return gcvalue(t1) == gcvalue(t2);
61 else switch (ttype(t1)) {
61 case LUA_TNIL: 62 case LUA_TNIL:
62 return 1; 63 return 1;
63 case LUA_TBOOLEAN: 64 case LUA_TBOOLEAN:
@@ -66,9 +67,9 @@ int luaO_rawequalObj (const TObject *t1, const TObject *t2) {
66 return pvalue(t1) == pvalue(t2); 67 return pvalue(t1) == pvalue(t2);
67 case LUA_TNUMBER: 68 case LUA_TNUMBER:
68 return nvalue(t1) == nvalue(t2); 69 return nvalue(t1) == nvalue(t2);
69 default:
70 return gcvalue(t1) == gcvalue(t2);
71 } 70 }
71 lua_assert(0);
72 return 0; /* to avoid warnings */
72} 73}
73 74
74 75