diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-15 11:23:35 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2024-03-15 11:23:35 -0300 |
commit | ba710603811c68fe3a69b3bb98e9038d37489a79 (patch) | |
tree | c960f80517482d4baa33f92dd7f9b9002b24f365 /ltable.h | |
parent | 3823fc6c814d20f2b2a0a1e3be8782084440040f (diff) | |
download | lua-ba710603811c68fe3a69b3bb98e9038d37489a79.tar.gz lua-ba710603811c68fe3a69b3bb98e9038d37489a79.tar.bz2 lua-ba710603811c68fe3a69b3bb98e9038d37489a79.zip |
Removed "bulk operations"
Negligible performance gains don't justify extra complexity.
Diffstat (limited to 'ltable.h')
-rw-r--r-- | ltable.h | 18 |
1 files changed, 3 insertions, 15 deletions
@@ -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 | |||
105 | struct ArrayCell { | 96 | struct 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]) |