aboutsummaryrefslogtreecommitdiff
path: root/ltm.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-10 20:10:30 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2001-12-10 20:10:30 -0200
commita4c35a3269f0581da212b3c4abd04989f88425ce (patch)
treee46d6548e1ccbae3cfd4af102eedd881d0454e55 /ltm.c
parent9cd36059ad6f3f6750b8cff54c305ae347c6caca (diff)
downloadlua-a4c35a3269f0581da212b3c4abd04989f88425ce.tar.gz
lua-a4c35a3269f0581da212b3c4abd04989f88425ce.tar.bz2
lua-a4c35a3269f0581da212b3c4abd04989f88425ce.zip
it doesn't pay to optimize absence when it is an error
Diffstat (limited to 'ltm.c')
-rw-r--r--ltm.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/ltm.c b/ltm.c
index 5d1c83d1..5e5f1ab2 100644
--- a/ltm.c
+++ b/ltm.c
@@ -39,6 +39,10 @@ void luaT_init (lua_State *L) {
39} 39}
40 40
41 41
42/*
43** function to be used with macro "fasttm": optimized for absence of
44** tag methods
45*/
42const TObject *luaT_gettm (Table *events, TMS event, TString *ename) { 46const TObject *luaT_gettm (Table *events, TMS event, TString *ename) {
43 const TObject *tm = luaH_getstr(events, ename); 47 const TObject *tm = luaH_getstr(events, ename);
44 if (ttype(tm) == LUA_TNIL) { /* no tag method? */ 48 if (ttype(tm) == LUA_TNIL) { /* no tag method? */
@@ -50,13 +54,14 @@ const TObject *luaT_gettm (Table *events, TMS event, TString *ename) {
50 54
51 55
52const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) { 56const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) {
57 TString *ename = G(L)->tmname[event];
53 switch (ttype(o)) { 58 switch (ttype(o)) {
54 case LUA_TTABLE: 59 case LUA_TTABLE:
55 return fasttm(L, hvalue(o)->eventtable, event); 60 return luaH_getstr(hvalue(o)->eventtable, ename);
56 case LUA_TUSERDATA: 61 case LUA_TUSERDATA:
57 return fasttm(L, uvalue(o)->uv.eventtable, event); 62 return luaH_getstr(uvalue(o)->uv.eventtable, ename);
58 default: 63 default:
59 return NULL; 64 return &luaO_nilobject;
60 } 65 }
61} 66}
62 67