diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:32:34 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2002-03-04 18:32:34 -0300 |
| commit | 1a3f175640251437e60ca9a29131e289be624a5b (patch) | |
| tree | f40a16fd7bc2924bef72385fe7654e03f8567294 | |
| parent | 88c7b574cb5ac0402178b9c61fabe8fc50152e3c (diff) | |
| download | lua-1a3f175640251437e60ca9a29131e289be624a5b.tar.gz lua-1a3f175640251437e60ca9a29131e289be624a5b.tar.bz2 lua-1a3f175640251437e60ca9a29131e289be624a5b.zip | |
small optimization
| -rw-r--r-- | lgc.c | 18 |
1 files changed, 9 insertions, 9 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 1.1 2001/11/29 22:14:34 rieru Exp rieru $ | 2 | ** $Id: lgc.c,v 1.127 2002/01/30 17:26:44 roberto Exp roberto $ |
| 3 | ** Garbage Collector | 3 | ** Garbage Collector |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -43,7 +43,12 @@ typedef struct GCState { | |||
| 43 | 43 | ||
| 44 | 44 | ||
| 45 | 45 | ||
| 46 | static void markobject (GCState *st, TObject *o); | 46 | #define ismarkable(o) (!((1 << ttype(o)) & \ |
| 47 | ((1 << LUA_TNIL) | (1 << LUA_TNUMBER) | (1 << LUA_TBOOLEAN)))) | ||
| 48 | |||
| 49 | static void reallymarkobject (GCState *st, TObject *o); | ||
| 50 | |||
| 51 | #define markobject(st,o) if (ismarkable(o)) reallymarkobject(st,o) | ||
| 47 | 52 | ||
| 48 | 53 | ||
| 49 | static void protomark (Proto *f) { | 54 | static void protomark (Proto *f) { |
| @@ -96,7 +101,7 @@ static void marktable (GCState *st, Table *h) { | |||
| 96 | } | 101 | } |
| 97 | 102 | ||
| 98 | 103 | ||
| 99 | static void markobject (GCState *st, TObject *o) { | 104 | static void reallymarkobject (GCState *st, TObject *o) { |
| 100 | switch (ttype(o)) { | 105 | switch (ttype(o)) { |
| 101 | case LUA_TSTRING: | 106 | case LUA_TSTRING: |
| 102 | strmark(tsvalue(o)); | 107 | strmark(tsvalue(o)); |
| @@ -112,12 +117,7 @@ static void markobject (GCState *st, TObject *o) { | |||
| 112 | marktable(st, hvalue(o)); | 117 | marktable(st, hvalue(o)); |
| 113 | break; | 118 | break; |
| 114 | } | 119 | } |
| 115 | default: { | 120 | default: lua_assert(0); /* should not be called with other types */ |
| 116 | lua_assert(ttype(o) == LUA_TNIL || | ||
| 117 | ttype(o) == LUA_TNUMBER || | ||
| 118 | ttype(o) == LUA_TBOOLEAN); | ||
| 119 | break; | ||
| 120 | } | ||
| 121 | } | 121 | } |
| 122 | } | 122 | } |
| 123 | 123 | ||
