diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-12-10 20:10:30 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-12-10 20:10:30 -0200 |
commit | a4c35a3269f0581da212b3c4abd04989f88425ce (patch) | |
tree | e46d6548e1ccbae3cfd4af102eedd881d0454e55 /ltm.c | |
parent | 9cd36059ad6f3f6750b8cff54c305ae347c6caca (diff) | |
download | lua-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.c | 11 |
1 files changed, 8 insertions, 3 deletions
@@ -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 | */ | ||
42 | const TObject *luaT_gettm (Table *events, TMS event, TString *ename) { | 46 | const 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 | ||
52 | const TObject *luaT_gettmbyobj (lua_State *L, const TObject *o, TMS event) { | 56 | const 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 | ||