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.c | |
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.c')
-rw-r--r-- | ltable.c | 17 |
1 files changed, 4 insertions, 13 deletions
@@ -665,7 +665,7 @@ static void reinsertOldSlice (lua_State *L, Table *t, unsigned oldasize, | |||
665 | int tag = *getArrTag(t, i); | 665 | int tag = *getArrTag(t, i); |
666 | if (!tagisempty(tag)) { /* a non-empty entry? */ | 666 | if (!tagisempty(tag)) { /* a non-empty entry? */ |
667 | TValue aux; | 667 | TValue aux; |
668 | farr2val(t, i + 1, tag, &aux); | 668 | farr2val(t, i + 1, tag, &aux); /* copy entry into 'aux' */ |
669 | luaH_setint(L, t, i + 1, &aux); /* re-insert it into the table */ | 669 | luaH_setint(L, t, i + 1, &aux); /* re-insert it into the table */ |
670 | } | 670 | } |
671 | } | 671 | } |
@@ -673,21 +673,12 @@ static void reinsertOldSlice (lua_State *L, Table *t, unsigned oldasize, | |||
673 | } | 673 | } |
674 | 674 | ||
675 | 675 | ||
676 | #define BK1(x) cast(lua_Unsigned, ((x) << 8) | LUA_VEMPTY) | ||
677 | |||
678 | /* | 676 | /* |
679 | ** Clear new slice of the array, in bulk. | 677 | ** Clear new slice of the array. |
680 | */ | 678 | */ |
681 | static void clearNewSlice (Table *t, unsigned oldasize, unsigned newasize) { | 679 | static void clearNewSlice (Table *t, unsigned oldasize, unsigned newasize) { |
682 | int i, j; | 680 | for (; oldasize < newasize; oldasize++) |
683 | int firstcell = (oldasize + NM - 1) / NM; | 681 | *getArrTag(t, oldasize) = LUA_VEMPTY; |
684 | int lastcell = cast_int((newasize + NM - 1) / NM) - 1; | ||
685 | for (i = firstcell; i <= lastcell; i++) { | ||
686 | /* empty tag repeated for all tags in a word */ | ||
687 | const lua_Unsigned empty = BK1(BK1(BK1(BK1(BK1(BK1(BK1(BK1(0)))))))); | ||
688 | for (j = 0; j < BKSZ; j++) | ||
689 | t->array[i].u.bulk[j] = empty; | ||
690 | } | ||
691 | } | 682 | } |
692 | 683 | ||
693 | 684 | ||