diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-10-25 17:14:14 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-10-25 17:14:14 -0200 |
commit | 21aa7e55f2333e57b972aa4ef2c5e2785d609578 (patch) | |
tree | bdd6119f0fab0178979202bc5d0afbd6f4410469 /lobject.h | |
parent | fffb6f3814084cddd8a58e81ae1b73ed78ea0953 (diff) | |
download | lua-21aa7e55f2333e57b972aa4ef2c5e2785d609578.tar.gz lua-21aa7e55f2333e57b972aa4ef2c5e2785d609578.tar.bz2 lua-21aa7e55f2333e57b972aa4ef2c5e2785d609578.zip |
optimization for array part of a Table
Diffstat (limited to 'lobject.h')
-rw-r--r-- | lobject.h | 26 |
1 files changed, 17 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.h,v 1.113 2001/09/25 17:08:46 roberto Exp $ | 2 | ** $Id: lobject.h,v 1.114 2001/10/02 16:45:03 roberto Exp $ |
3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -39,7 +39,7 @@ typedef union { | |||
39 | union TString *ts; | 39 | union TString *ts; |
40 | union Udata *u; | 40 | union Udata *u; |
41 | union Closure *cl; | 41 | union Closure *cl; |
42 | struct Hash *h; | 42 | struct Table *h; |
43 | struct UpVal *v; | 43 | struct UpVal *v; |
44 | lua_Number n; /* LUA_TNUMBER */ | 44 | lua_Number n; /* LUA_TNUMBER */ |
45 | } Value; | 45 | } Value; |
@@ -214,7 +214,7 @@ typedef union Closure { | |||
214 | 214 | ||
215 | 215 | ||
216 | /* | 216 | /* |
217 | ** Hash Tables | 217 | ** Tables |
218 | */ | 218 | */ |
219 | 219 | ||
220 | typedef struct Node { | 220 | typedef struct Node { |
@@ -224,15 +224,17 @@ typedef struct Node { | |||
224 | } Node; | 224 | } Node; |
225 | 225 | ||
226 | 226 | ||
227 | typedef struct Hash { | 227 | typedef struct Table { |
228 | TObject *array; /* array part */ | ||
228 | Node *node; | 229 | Node *node; |
229 | int htag; | 230 | int htag; |
230 | int size; | 231 | int sizearray; /* size of `array' array */ |
232 | lu_byte lsizenode; /* log2 of size of `node' array */ | ||
233 | lu_byte weakmode; | ||
231 | Node *firstfree; /* this position is free; all positions after it are full */ | 234 | Node *firstfree; /* this position is free; all positions after it are full */ |
232 | struct Hash *next; | 235 | struct Table *next; |
233 | struct Hash *mark; /* marked tables (point to itself when not marked) */ | 236 | struct Table *mark; /* marked tables (point to itself when not marked) */ |
234 | int weakmode; | 237 | } Table; |
235 | } Hash; | ||
236 | 238 | ||
237 | 239 | ||
238 | /* unmarked tables are represented by pointing `mark' to themselves */ | 240 | /* unmarked tables are represented by pointing `mark' to themselves */ |
@@ -245,6 +247,10 @@ typedef struct Hash { | |||
245 | #define lmod(s,size) (cast(int, (s) & ((size)-1))) | 247 | #define lmod(s,size) (cast(int, (s) & ((size)-1))) |
246 | 248 | ||
247 | 249 | ||
250 | #define twoto(x) (1<<(x)) | ||
251 | #define sizenode(t) (twoto((t)->lsizenode)) | ||
252 | #define sizearray(t) ((t)->sizearray) | ||
253 | |||
248 | /* | 254 | /* |
249 | ** informations about a call (for debugging) | 255 | ** informations about a call (for debugging) |
250 | */ | 256 | */ |
@@ -262,6 +268,8 @@ typedef struct CallInfo { | |||
262 | 268 | ||
263 | extern const TObject luaO_nilobject; | 269 | extern const TObject luaO_nilobject; |
264 | 270 | ||
271 | int luaO_log2 (unsigned int x); | ||
272 | |||
265 | 273 | ||
266 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) | 274 | #define luaO_openspace(L,n,t) cast(t *, luaO_openspaceaux(L,(n)*sizeof(t))) |
267 | void *luaO_openspaceaux (lua_State *L, size_t n); | 275 | void *luaO_openspaceaux (lua_State *L, size_t n); |