diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-23 10:16:18 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-23 10:16:18 -0300 |
| commit | 9243c414d92c253edd908f438caa31e2aa16f3f4 (patch) | |
| tree | e8959a48f4672037aef061cc6eb82bba21d0766b /lvm.h | |
| parent | 477ca2fe8ceaf79038972977915987adbef0e425 (diff) | |
| download | lua-9243c414d92c253edd908f438caa31e2aa16f3f4.tar.gz lua-9243c414d92c253edd908f438caa31e2aa16f3f4.tar.bz2 lua-9243c414d92c253edd908f438caa31e2aa16f3f4.zip | |
first version of empty entries in tables
(so that, in the future, tables can contain regular nil entries)
Diffstat (limited to 'lvm.h')
| -rw-r--r-- | lvm.h | 10 |
1 files changed, 5 insertions, 5 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.h,v 2.49 2018/02/19 20:06:56 roberto Exp roberto $ | 2 | ** $Id: lvm.h,v 2.50 2018/02/21 12:54:26 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -64,17 +64,17 @@ | |||
| 64 | 64 | ||
| 65 | 65 | ||
| 66 | /* | 66 | /* |
| 67 | ** fast track for 'gettable': if 't' is a table and 't[k]' is not nil, | 67 | ** fast track for 'gettable': if 't' is a table and 't[k]' is present, |
| 68 | ** return 1 with 'slot' pointing to 't[k]' (position of final result). | 68 | ** return 1 with 'slot' pointing to 't[k]' (position of final result). |
| 69 | ** Otherwise, return 0 (meaning it will have to check metamethod) | 69 | ** Otherwise, return 0 (meaning it will have to check metamethod) |
| 70 | ** with 'slot' pointing to a nil 't[k]' (if 't' is a table) or NULL | 70 | ** with 'slot' pointing to an empty 't[k]' (if 't' is a table) or NULL |
| 71 | ** (otherwise). 'f' is the raw get function to use. | 71 | ** (otherwise). 'f' is the raw get function to use. |
| 72 | */ | 72 | */ |
| 73 | #define luaV_fastget(L,t,k,slot,f) \ | 73 | #define luaV_fastget(L,t,k,slot,f) \ |
| 74 | (!ttistable(t) \ | 74 | (!ttistable(t) \ |
| 75 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ | 75 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ |
| 76 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ | 76 | : (slot = f(hvalue(t), k), /* else, do raw access */ \ |
| 77 | !ttisnil(slot))) /* result not nil? */ | 77 | !isempty(slot))) /* result not empty? */ |
| 78 | 78 | ||
| 79 | 79 | ||
| 80 | /* | 80 | /* |
| @@ -86,7 +86,7 @@ | |||
| 86 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ | 86 | ? (slot = NULL, 0) /* not a table; 'slot' is NULL and result is 0 */ \ |
| 87 | : (slot = (l_castS2U(k) - 1u < hvalue(t)->sizearray) \ | 87 | : (slot = (l_castS2U(k) - 1u < hvalue(t)->sizearray) \ |
| 88 | ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ | 88 | ? &hvalue(t)->array[k - 1] : luaH_getint(hvalue(t), k), \ |
| 89 | !ttisnil(slot))) /* result not nil? */ | 89 | !isempty(slot))) /* result not empty? */ |
| 90 | 90 | ||
| 91 | 91 | ||
| 92 | /* | 92 | /* |
