Removed "bulk operations"

Negligible performance gains don't justify extra complexity.
This commit is contained in:
Roberto Ierusalimschy
2024-03-15 11:23:35 -03:00
parent 3823fc6c81
commit ba71060381
3 changed files with 14 additions and 57 deletions

View File

@@ -87,32 +87,20 @@
/*
** The array part of a table is represented by an array of *cells*.
** The array part of a table is represented by an array of cells.
** Each cell is composed of NM tags followed by NM values, so that
** no space is wasted in padding.
*/
#define NM cast_uint(sizeof(Value))
/*
** A few operations on arrays can be performed "in bulk", treating all
** tags of a cell as a simple (or a few) word(s). The next constant is
** the number of words to cover the tags of a cell. (In conventional
** architectures that will be 1 or 2.)
*/
#define BKSZ cast_int((NM - 1) / sizeof(lua_Unsigned) + 1)
struct ArrayCell {
union {
lua_Unsigned bulk[BKSZ]; /* for "bulk" operations */
lu_byte tag[NM];
} u;
lu_byte tag[NM];
Value value[NM];
};
/* Computes the address of the tag for the abstract index 'k' */
#define getArrTag(t,k) (&(t)->array[(k)/NM].u.tag[(k)%NM])
#define getArrTag(t,k) (&(t)->array[(k)/NM].tag[(k)%NM])
/* Computes the address of the value for the abstract index 'k' */
#define getArrVal(t,k) (&(t)->array[(k)/NM].value[(k)%NM])