aboutsummaryrefslogtreecommitdiff
path: root/ltable.h
diff options
context:
space:
mode:
Diffstat (limited to 'ltable.h')
-rw-r--r--ltable.h18
1 files changed, 3 insertions, 15 deletions
diff --git a/ltable.h b/ltable.h
index 8688264c..8b0340b5 100644
--- a/ltable.h
+++ b/ltable.h
@@ -87,32 +87,20 @@
87 87
88 88
89/* 89/*
90** The array part of a table is represented by an array of *cells*. 90** The array part of a table is represented by an array of cells.
91** Each cell is composed of NM tags followed by NM values, so that 91** Each cell is composed of NM tags followed by NM values, so that
92** no space is wasted in padding. 92** no space is wasted in padding.
93*/ 93*/
94#define NM cast_uint(sizeof(Value)) 94#define NM cast_uint(sizeof(Value))
95 95
96
97/*
98** A few operations on arrays can be performed "in bulk", treating all
99** tags of a cell as a simple (or a few) word(s). The next constant is
100** the number of words to cover the tags of a cell. (In conventional
101** architectures that will be 1 or 2.)
102*/
103#define BKSZ cast_int((NM - 1) / sizeof(lua_Unsigned) + 1)
104
105struct ArrayCell { 96struct ArrayCell {
106 union { 97 lu_byte tag[NM];
107 lua_Unsigned bulk[BKSZ]; /* for "bulk" operations */
108 lu_byte tag[NM];
109 } u;
110 Value value[NM]; 98 Value value[NM];
111}; 99};
112 100
113 101
114/* Computes the address of the tag for the abstract index 'k' */ 102/* Computes the address of the tag for the abstract index 'k' */
115#define getArrTag(t,k) (&(t)->array[(k)/NM].u.tag[(k)%NM]) 103#define getArrTag(t,k) (&(t)->array[(k)/NM].tag[(k)%NM])
116 104
117/* Computes the address of the value for the abstract index 'k' */ 105/* Computes the address of the value for the abstract index 'k' */
118#define getArrVal(t,k) (&(t)->array[(k)/NM].value[(k)%NM]) 106#define getArrVal(t,k) (&(t)->array[(k)/NM].value[(k)%NM])