Commit Graph

37 Commits

Author SHA1 Message Date
Tetralux
fa2296a124 [runtime] Add builtin shrink for dynamic arrays and maps
Asks the allocator to shrink the backing allocation to the current __length__, or a capacity
of the user's choosing.

Returns `(did_shrink: bool, err: mem.Allocator_Error)`.

```
shrink(&array) // shrinks to len(array)
shrink(&array, N) // shrink to N capacity

shrink(&map) // shrinks down to len(map)
shrink(&map, N) // shrink to N capacity
```
2022-06-04 23:29:47 +00:00
gingerBill
802df73183 Remove unneeded call 2021-10-26 14:47:59 +01:00
gingerBill
c64674c39e Remove unnecessary asserts 2021-10-26 13:38:48 +01:00
gingerBill
d386563344 Correct issue with the generated map type internals; Simplify map rehash logic to utilize resize 2021-10-07 21:23:37 +01:00
gingerBill
e6d8fbf194 Add runtime.__get_map_header_runtime 2021-09-25 17:30:18 +01:00
gingerBill
868c923770 Make map internals more robust when using mem.nil_allocator() 2021-09-25 15:55:27 +01:00
gingerBill
720884e0f1 Strip even more semicolons if followed by a } or ) on the same line 2021-08-31 23:47:57 +01:00
gingerBill
251da264ed Remove unneeded semicolons from the core library 2021-08-31 22:21:13 +01:00
gingerBill
a5c31bbee0 Add map_insert which returns the pointer to inserted value 2021-08-29 11:45:11 +01:00
gingerBill
f0437a4242 Enforce core:builtin and core:intrinsics for imports 2021-08-21 13:44:16 +01:00
gingerBill
4d00c2b800 Allocator_Error.Mode_Not_Implemented; Minor improvement to map runtime procedures 2021-08-08 14:29:45 +01:00
gingerBill
9f8a63cb43 More minor stylization changes (remove unneeded parentheses) 2021-06-14 11:34:31 +01:00
gingerBill
f98c4d6837 Improve the Allocator interface to support returning Allocator_Error to allow for safer calls
Virtually all code (except for user-written custom allocators) should work as normal. Extra features will need to be added to make the current procedures support the `Allocator_Error` return value (akin to #optional_ok)
2021-04-19 12:31:31 +01:00
gingerBill
a60d22fefd Make trailing comma usage consistent 2021-03-13 21:18:07 +00:00
gingerBill
083cec6c88 Remove dead code 2021-03-06 16:11:54 +00:00
gingerBill
b727b6438b Minimize unneeded casts 2021-03-03 14:31:17 +00:00
gingerBill
79eb46bce3 Replace inline uses in the rest of core with #force_inline 2021-02-23 20:39:59 +00:00
gingerBill
aa93305015 Replace usage of inline proc with #force_inline proc in the core library 2021-02-23 16:14:47 +00:00
gingerBill
a1693c0184 Deprecate inline for in favour of #unroll for 2021-02-23 14:45:15 +00:00
gingerBill
5803fcc158 Revert function passes 2020-11-29 20:41:01 +00:00
gingerBill
f06f33872c Make 16 simple hasher cases for small types 2020-11-29 18:17:21 +00:00
gingerBill
57f5976ac1 Support map keys for simple compare types 2020-11-29 16:12:21 +00:00
gingerBill
1dfe0cdd1d Simplify hashing approach map 2020-11-29 15:50:29 +00:00
gingerBill
97c66c9c73 Add intrinsics.type_hasher_proc; Make map work with generic hasher procedure 2020-11-29 15:27:53 +00:00
gingerBill
085972bb2c Minor clean up 2020-11-29 14:31:42 +00:00
gingerBill
39bed567b3 Add intrinsics.type_equal_proc; Make map use an internal equal procedure to compare keys 2020-11-29 14:22:42 +00:00
gingerBill
2e0fd34e59 Keep -vet happy 2020-11-29 12:52:30 +00:00
gingerBill
9959a069fc Simplify internals of map[K]V 2020-11-29 12:48:33 +00:00
gingerBill
89cceb910a Keep -vet happy 2020-11-26 00:09:38 +00:00
gingerBill
f36c5de746 Fix typo 2020-11-26 00:05:15 +00:00
gingerBill
ca10248740 Add __dynamic_map_fix_keys 2020-11-25 23:50:25 +00:00
gingerBill
aa859c2187 Clean up and fix __dynamic_map_erase 2020-11-25 22:36:34 +00:00
gingerBill
8591655334 Clean up __dynamic_map_rehash behaviour 2020-11-25 21:03:20 +00:00
gingerBill
a55568b0c4 Make hash internal key be uintptr rather than u64 to reduce entry size 2020-11-23 19:14:36 +00:00
gingerBill
91758656f6 Change internal layout of map[K]V 2020-11-23 18:25:01 +00:00
gingerBill
4762d2f2d1 map type internal reorganization 2020-11-23 16:56:31 +00:00
gingerBill
913eac13b1 Reorganize runtime code into separate files 2020-11-19 00:08:23 +00:00