diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-06 15:06:19 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2009-11-06 15:06:19 -0200 |
| commit | a921d81033555e1c122834f0cd19bd8a17ac35c0 (patch) | |
| tree | 3e001d61078eef223d3e4ee9d9c3bfcb45d7d7cb | |
| parent | 155dd01163cb67f4ee64d828337b06b7753af295 (diff) | |
| download | lua-a921d81033555e1c122834f0cd19bd8a17ac35c0.tar.gz lua-a921d81033555e1c122834f0cd19bd8a17ac35c0.tar.bz2 lua-a921d81033555e1c122834f0cd19bd8a17ac35c0.zip | |
avoid using 'ttype' when there is an explicit test + macro 'checkdeadkey'
to avoid repetitions
| -rw-r--r-- | lgc.c | 12 |
1 files changed, 7 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lgc.c,v 2.58 2009/10/23 19:12:19 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.59 2009/11/05 17:43:54 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 | */ |
| @@ -42,6 +42,8 @@ | |||
| 42 | 42 | ||
| 43 | #define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) | 43 | #define isfinalized(u) testbit((u)->marked, FINALIZEDBIT) |
| 44 | 44 | ||
| 45 | #define checkdeadkey(n) lua_assert(!ttisdeadkey(gkey(n)) || ttisnil(gval(n))) | ||
| 46 | |||
| 45 | 47 | ||
| 46 | #define markvalue(g,o) { checkconsistency(o); \ | 48 | #define markvalue(g,o) { checkconsistency(o); \ |
| 47 | if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } | 49 | if (valiswhite(o)) reallymarkobject(g,gcvalue(o)); } |
| @@ -71,7 +73,7 @@ static void linktable (Table *h, GCObject **p) { | |||
| 71 | static void removeentry (Node *n) { | 73 | static void removeentry (Node *n) { |
| 72 | lua_assert(ttisnil(gval(n))); | 74 | lua_assert(ttisnil(gval(n))); |
| 73 | if (iscollectable(gkey(n))) | 75 | if (iscollectable(gkey(n))) |
| 74 | setttype(gkey(n), LUA_TDEADKEY); /* dead key; remove it */ | 76 | setdeadvalue(gkey(n)); /* dead key; remove it */ |
| 75 | } | 77 | } |
| 76 | 78 | ||
| 77 | 79 | ||
| @@ -252,7 +254,7 @@ static void traverseweakvalue (global_State *g, Table *h) { | |||
| 252 | int i = sizenode(h); | 254 | int i = sizenode(h); |
| 253 | while (i--) { | 255 | while (i--) { |
| 254 | Node *n = gnode(h, i); | 256 | Node *n = gnode(h, i); |
| 255 | lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); | 257 | checkdeadkey(n); |
| 256 | if (ttisnil(gval(n))) | 258 | if (ttisnil(gval(n))) |
| 257 | removeentry(n); /* remove empty entries */ | 259 | removeentry(n); /* remove empty entries */ |
| 258 | else { | 260 | else { |
| @@ -277,7 +279,7 @@ static int traverseephemeron (global_State *g, Table *h) { | |||
| 277 | i = sizenode(h); | 279 | i = sizenode(h); |
| 278 | while (i--) { | 280 | while (i--) { |
| 279 | Node *n = gnode(h, i); | 281 | Node *n = gnode(h, i); |
| 280 | lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); | 282 | checkdeadkey(n); |
| 281 | if (ttisnil(gval(n))) /* entry is empty? */ | 283 | if (ttisnil(gval(n))) /* entry is empty? */ |
| 282 | removeentry(n); /* remove it */ | 284 | removeentry(n); /* remove it */ |
| 283 | else if (valiswhite(gval(n))) { | 285 | else if (valiswhite(gval(n))) { |
| @@ -306,7 +308,7 @@ static void traversestrongtable (global_State *g, Table *h) { | |||
| 306 | i = sizenode(h); | 308 | i = sizenode(h); |
| 307 | while (i--) { | 309 | while (i--) { |
| 308 | Node *n = gnode(h, i); | 310 | Node *n = gnode(h, i); |
| 309 | lua_assert(ttype(gkey(n)) != LUA_TDEADKEY || ttisnil(gval(n))); | 311 | checkdeadkey(n); |
| 310 | if (ttisnil(gval(n))) | 312 | if (ttisnil(gval(n))) |
| 311 | removeentry(n); /* remove empty entries */ | 313 | removeentry(n); /* remove empty entries */ |
| 312 | else { | 314 | else { |
