diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-17 10:18:01 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-17 10:18:01 -0300 |
commit | 90fb2e18e84075972d1937a6c0a3c2624756a3db (patch) | |
tree | 78972c91056663b7532c2e2a1182ee95654e3d34 /lref.c | |
parent | 4365c31c89666bae24afd800ac3251527d9dc9c8 (diff) | |
download | lua-90fb2e18e84075972d1937a6c0a3c2624756a3db.tar.gz lua-90fb2e18e84075972d1937a6c0a3c2624756a3db.tar.bz2 lua-90fb2e18e84075972d1937a6c0a3c2624756a3db.zip |
`pushref' is more efficient (and probably more useful) than `getref'.
Diffstat (limited to 'lref.c')
-rw-r--r-- | lref.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lref.c,v 1.16 2000/08/07 20:21:34 roberto Exp roberto $ | 2 | ** $Id: lref.c,v 1.17 2000/08/09 19:16:57 roberto Exp roberto $ |
3 | ** reference mechanism | 3 | ** reference mechanism |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -8,6 +8,7 @@ | |||
8 | #include "lua.h" | 8 | #include "lua.h" |
9 | 9 | ||
10 | #include "lapi.h" | 10 | #include "lapi.h" |
11 | #include "ldo.h" | ||
11 | #include "lmem.h" | 12 | #include "lmem.h" |
12 | #include "lref.h" | 13 | #include "lref.h" |
13 | #include "lstate.h" | 14 | #include "lstate.h" |
@@ -47,14 +48,16 @@ void lua_unref (lua_State *L, int ref) { | |||
47 | } | 48 | } |
48 | 49 | ||
49 | 50 | ||
50 | lua_Object lua_getref (lua_State *L, int ref) { | 51 | int lua_pushref (lua_State *L, int ref) { |
51 | if (ref == LUA_REFNIL) | 52 | if (ref == LUA_REFNIL) |
52 | return luaA_putluaObject(L, &luaO_nilobject); | 53 | ttype(L->top) = TAG_NIL; |
53 | else if (0 <= ref && ref < L->refSize && | 54 | else if (0 <= ref && ref < L->refSize && |
54 | (L->refArray[ref].st == LOCK || L->refArray[ref].st == HOLD)) | 55 | (L->refArray[ref].st == LOCK || L->refArray[ref].st == HOLD)) |
55 | return luaA_putluaObject(L, &L->refArray[ref].o); | 56 | *L->top = L->refArray[ref].o; |
56 | else | 57 | else |
57 | return LUA_NOOBJECT; | 58 | return 0; |
59 | incr_top; | ||
60 | return 1; | ||
58 | } | 61 | } |
59 | 62 | ||
60 | 63 | ||