aboutsummaryrefslogtreecommitdiff
path: root/ltable.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
* Add extra size when resizing tables with deleted keysRoberto Ierusalimschy2024-11-141-5/+21
| | | | | | | | Without this extra space, sequences of insertions/deletions (and some other uses) can have unpexpected low performances. See the added tests for an example, and *Mathematical Models to Analyze Lua Hybrid Tables and Why They Need a Fix* (Martínez, Nicaud, Rotondo; arXiv:2208.13602v2) for detais.
* New rule for size of array partRoberto Ierusalimschy2024-11-131-7/+20
| | | | | | | | Array part needs 1/3 of its elements filled, instead of 1/2. Array entries use ~1/3 the memory of hash entries, so this new rule still ensures that array parts do not use more memory than keeping the values in the hash, while allowing more uses of the array part, which is more efficient than the hash.
* New structure to count keys in a table for rehashingRoberto Ierusalimschy2024-10-281-50/+65
|
* Table rehash can resize only the hash partRoberto Ierusalimschy2024-10-281-14/+19
| | | | | | | If there are no integer keys outside the array part, there is no reason to resize it, saving the time to count its elements. Moreover, assignments to non-integer keys will not collapse a table created with 'table.create'.
* Always use unsigned int for indexing table-arraysRoberto Ierusalimschy2024-10-241-4/+4
|
* 'objsize' broke in smaller piecesRoberto Ierusalimschy2024-09-301-0/+12
|
* Avoid Microsoft warningRoberto Ierusalimschy2024-09-191-1/+2
| | | | | > warning C4334: '<<': result of 32-bit shift implicitly converted to > 64 bits (was 64-bit shift intended?)
* Added gcc option '-Wconversion'Roberto Ierusalimschy2024-07-271-33/+34
| | | | | No warnings for standard numerical types. Still pending alternative numerical types.
* 'isIT'/'isOT' turned from macros to functionsRoberto Ierusalimschy2024-06-271-1/+1
|
* Encoding of table indices (hres) must use C indicesRoberto Ierusalimschy2024-06-101-6/+6
| | | | | As the encoding of array indices is (~index), 0 is encoded as -1 and INT_MAX is encoded as INT_MIN.
* Yet another representation for arraysRoberto Ierusalimschy2024-04-051-23/+44
| | | | | | This "linear" representation (see ltable.h for details) has worse locality than cells, but the simpler access code seems to compensate that.
* Some 'unsigned int' changed to 'unsigned'Roberto Ierusalimschy2024-03-221-10/+10
| | | | | 'unsigned int' is too long sometimes. (We already write 'long' instead of 'long int'...)
* 'luaH_get' functions return tag of the resultRoberto Ierusalimschy2024-03-211-18/+30
| | | | | | | Undoing previous commit. Returning TValue increases code size without any visible gains. Returning the tag is a little simpler than returning a special code (HOK/HNOTFOUND) and the tag is useful by itself in some cases.
* 'luaH_get' functions return 'TValue'Roberto Ierusalimschy2024-03-181-35/+18
| | | | | | Instead of receiving a parameter telling them where to put the result of the query, these functions return the TValue directly. (That is, they return a structure.)
* Removed "bulk operations"Roberto Ierusalimschy2024-03-151-13/+4
| | | | Negligible performance gains don't justify extra complexity.
* Added "bulk operations" to arraysRoberto Ierusalimschy2024-03-151-15/+42
| | | | | A few operations on arrays can be performed "in bulk", treating all tags of a cell as a simple (or a few) word(s).
* Fixed warnings from different compilersRoberto Ierusalimschy2024-02-151-1/+2
|
* Field 'lastfree' changed (back) to 'Node *'Roberto Ierusalimschy2024-02-071-14/+16
| | | | | Due to allignment, it is already using the space of a pointer, and a pointer generates slightly simpler code.
* Better handling of size limit when resizing a tableRoberto Ierusalimschy2024-02-071-4/+13
| | | | | | | | Avoid silent conversions from int to unsigned int when calling 'luaH_resize'; avoid silent conversions from lua_Integer to int in 'table.create'; MAXASIZE corrected for the new implementation of arrays; 'luaH_resize' checks explicitly whether new size respects MAXASIZE. (Even constructors were bypassing that check.)
* Small optimization in 'luaH_psetint'Roberto Ierusalimschy2024-01-251-1/+1
| | | | | | It is quite common to write to empty but existing cells in the array part of a table, so 'luaH_psetint' checks for the common case that the table doesn't have a newindex metamethod to complete the write.
* Optimizations for 'lua_rawgeti' and 'lua_rawseti'Roberto Ierusalimschy2024-01-121-18/+37
| | | | | | 'lua_rawgeti' now uses "fast track"; 'lua_rawseti' still calls 'luaH_setint', but the latter was recoded to avoid extra overhead when writing to the array part after 'alimit'.
* Simpler coding for new representation for arraysRoberto Ierusalimschy2023-11-241-19/+27
| | | | | With the tags comming first in a cell, we can define the whole cell as a C type and let C do part of the address computations.
* Merge branch 'newarray' into nextversionRoberto Ierusalimschy2023-11-071-84/+244
|\
| * Merge branch 'master' into newarrayRoberto Ierusalimschy2023-11-031-2/+3
| |\
| * | Full implementation of new representation for arraysRoberto Ierusalimschy2023-11-031-9/+37
| | |
| * | Full abstraction for representation of array valuesRoberto Ierusalimschy2023-10-301-56/+60
| | |
| * | Avoid direct accesses to the array part of a tableRoberto Ierusalimschy2023-10-271-49/+79
| | |
| * | Some cleaning in the new table APIRoberto Ierusalimschy2023-05-161-50/+52
| | |
| * | New table API for 'set' functionsRoberto Ierusalimschy2023-05-161-20/+100
| | |
| * | Towards a new implementation of arraysRoberto Ierusalimschy2023-05-151-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The array part of a table wastes too much space, due to padding. To avoid that, we need to store values in the array as something different from a TValue. Therefore, the API for table access should not assume that any value in a table lives in a *TValue. This commit is the first step to remove that assumption: functions luaH_get*, instead of returning a *TValue where the value lives, receive a *TValue where to put the value being accessed. (We still have to change the luaH_set* functions.)
* | | Merge branch 'master' into nextversionRoberto Ierusalimschy2023-11-071-11/+25
|\ \ \ | | |/ | |/|
| * | Simpler test in 'luaH_getint'Roberto Ierusalimschy2023-10-261-11/+25
| | | | | | | | | | | | | | | The test whether key is inside the array part of a table uses a bit trick to avoid computing the real size of the array part.
* | | Merge branch 'master' into nextversionRoberto Ierusalimschy2023-06-221-1/+4
|\| |
| * | DetailsRoberto Ierusalimschy2023-05-151-1/+2
| |/ | | | | | | | | - Better comments about short strings in opcodes. - luaH_newkey made static.
| * Corrected support for 16-bit systemsRoberto Ierusalimschy2023-03-091-0/+2
| | | | | | | | | | We still need access to a 16-bit system to correctly test these changes.
* | Tables have a 'lastfree' information only when neededRoberto Ierusalimschy2022-11-011-15/+65
|/ | | | | Only tables with some minimum number of entries in their hash part have a 'lastfree' field, kept in a header before the node vector.
* Removed test function 'luaH_isdummy'Roberto Ierusalimschy2022-10-211-2/+0
| | | | It was not being used anywhere.
* DetailsRoberto Ierusalimschy2022-10-191-2/+2
| | | | Some cast operations rewritten to use respective macros.
* Main 'mainposition' replaced by 'mainpositionTV'Roberto Ierusalimschy2021-11-251-19/+16
| | | | | Handle values in table keys as the special cases they are, and not the other way around.
* Avoid taking the address of a 'TValue' fieldRoberto Ierusalimschy2021-10-111-9/+9
| | | | That structure can be packed in the future.
* New hash function for integer keysRoberto Ierusalimschy2021-03-291-2/+14
| | | | | | | When integer keys do not form a sequence, it is better to use all their bits to compute their hashes. (The previous implementation was quite bad for integer keys with common lower bits, and disastrous for integer keys changing only in their upper 32 bits.)
* DetailsRoberto Ierusalimschy2021-03-121-21/+40
| | | | Comments and order of hashing macros in 'ltable.c'.
* Broadening the use of branch hintsRoberto Ierusalimschy2021-02-241-4/+4
| | | | | | More uses of macros 'likely'/'unlikely' (renamed to 'l_likely'/'l_unlikely'), both in range (extended to the libraries) and in scope (extended to hooks, stack growth).
* Do not insert nil values into tablesRoberto Ierusalimschy2020-12-291-0/+2
|
* Changes in the API of 'luaH_set' and related functionsRoberto Ierusalimschy2020-12-041-15/+27
| | | | | Functions to set values in a table (luaH_set, luaH_newkey, etc.) receive the new value, instead of returning a slot where to put the value.
* CommentsRoberto Ierusalimschy2020-10-221-10/+17
|
* Fixed bug of keys removed from tables vs 'next'Roberto Ierusalimschy2020-10-141-10/+17
| | | | | | Fixed the bug that a key removed from a table might not be found again by 'next'. (This is needed to allow keys to be removed during a traversal.) This bug was introduced in commit 73ec04fc.
* Free bit 7 of GC 'marked' fieldRoberto Ierusalimschy2020-08-071-1/+1
| | | | | | | | Tables were using this bit to indicate their array sizes were real ('isrealasize'), but this bit can be useful for tests. Instead, they can use bit 7 of their 'flag' field for that purpose. (There are only six fast-access metamethods.) This 'flag' field only exists in tables, so this use does not affect other types.
* Clearer distinction between types and tagsRoberto Ierusalimschy2020-01-311-23/+23
| | | | | LUA_T* represents only types; tags (types + Variants) are represented by LUA_V* constants.
* Changed internal representation of booleansRoberto Ierusalimschy2020-01-061-5/+5
| | | | | | | Instead of an explicit value (field 'b'), true and false use different tag variants. This avoids reading an extra field and results in more direct code. (Most code that uses booleans needs to distinguish between true and false anyway.)