aboutsummaryrefslogtreecommitdiff
path: root/lref.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-17 10:18:01 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2000-08-17 10:18:01 -0300
commit90fb2e18e84075972d1937a6c0a3c2624756a3db (patch)
tree78972c91056663b7532c2e2a1182ee95654e3d34 /lref.c
parent4365c31c89666bae24afd800ac3251527d9dc9c8 (diff)
downloadlua-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.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/lref.c b/lref.c
index 7f144ba6..c3fc57af 100644
--- a/lref.c
+++ b/lref.c
@@ -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
50lua_Object lua_getref (lua_State *L, int ref) { 51int 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