Behdad Esfahbod
97ea10a63a
Remove old nullptr_t hacks
...
Were used for hashmap before.
2022-06-02 11:23:38 -06:00
Behdad Esfahbod
3f78a71ca0
[map] Finally! Just can usd hb_hashmap_t<obj_t, obj_t>
...
Yay!
2022-06-02 11:23:37 -06:00
Behdad Esfahbod
0ccab339f9
[map] Remove invalid-key template arguments since unused
2022-06-02 11:23:37 -06:00
Behdad Esfahbod
3f6a8f69a0
[map] Remove invalid-key special-casing
...
Can override invalid-key value now.
2022-06-02 11:23:37 -06:00
Behdad Esfahbod
5328b73fba
[map] Reduce map item size again
2022-06-02 11:23:37 -06:00
Behdad Esfahbod
4f58ae60eb
[map] Keep is_used, is_tombstone as booleans
2022-06-02 11:23:37 -06:00
Behdad Esfahbod
ea2dd54b68
[map] Place item hash between key and value, not after them
...
This way if only one of key and value is 64bit (eg. pointer), and other is 32bit,
the whole item will fit in 128bit, whereas before it would have been bumped up to
196 if only value was 64bit (a common use-case for us.)
2022-05-30 05:54:20 -06:00
Behdad Esfahbod
cbcdf442c5
[map] Speed up map's own hash()
2022-05-30 05:54:20 -06:00
Behdad Esfahbod
de33ef61b7
[map] Add TODO item
2022-05-30 05:54:20 -06:00
Behdad Esfahbod
b99efa6c8d
[map] Minor: use const reference in has()
2022-05-28 05:16:34 -06:00
Behdad Esfahbod
2fdb7616f5
[map Further adjust hash function
2022-05-19 16:00:43 -06:00
Behdad Esfahbod
01fc90b68c
[map] Adjust hash function
2022-05-19 16:00:06 -06:00
Behdad Esfahbod
58f848daa8
[set/map] Adjust hash function return type
2022-05-19 15:43:19 -06:00
Behdad Esfahbod
561e02fefb
[map] Make hb_map_t hashable
2022-05-19 13:41:53 -06:00
Behdad Esfahbod
ad17699089
[map] Add is_equal() / towards making hb_map_t hashable
...
New API:
+ hb_map_is_equal()
2022-05-19 13:36:12 -06:00
Behdad Esfahbod
f82ee17a75
[map] Pre-size map in constructor if we can
2022-05-18 12:19:49 -06:00
Behdad Esfahbod
7fa580bc4f
[map] Fix map copy/move constructors to actually work
...
Ouch!
2022-05-12 13:05:32 -06:00
Garret Rieger
e30511a8de
[map] Correct previous commit, if (...) was reversed.
2022-01-14 16:48:42 -08:00
Garret Rieger
ff4e8c7eac
[map] Fix bad memory access if hb_map.fini() was called twice.
2022-01-14 16:42:39 -08:00
Behdad Esfahbod
8a69e00639
[meta] Use std::addressof() instead of hb_addressof()
2022-01-13 16:17:34 -07:00
Behdad Esfahbod
47afb3ef04
[meta] Replace hb_is_pointer with std::is_pointer
2022-01-13 15:27:41 -07:00
Behdad Esfahbod
956e0a4d13
[map] Destruct objects
2022-01-13 15:07:10 -07:00
Behdad Esfahbod
985b63b3ee
[map] Allow invalid items to be pointer to static object
...
By derefencing them when necessary.
Also, we do not rely on trivially-copyable, so remove that assertion.
2022-01-13 13:33:07 -07:00
Behdad Esfahbod
5a91db1135
[map] Remove constexpr invalid items
...
These were non-workable in the general case, eg std::string.
2022-01-13 12:44:48 -07:00
Behdad Esfahbod
114046dc27
[map] Construct objects
2022-01-13 12:38:26 -07:00
Behdad Esfahbod
ca4f56bdc7
[map] Massage some more
...
Towards being able to store arbitrary types.
2022-01-13 12:18:59 -07:00
Behdad Esfahbod
74811c501d
[map] Map == / != use correct types
2022-01-12 10:35:28 -07:00
Behdad Esfahbod
ce7f19a2cc
Revert "[map] Actually use k/v invalid types for declaration!"
...
This reverts commit 6f559346ac
.
Err. My bad.
2022-01-10 14:40:27 -07:00
Behdad Esfahbod
6f559346ac
[map] Actually use k/v invalid types for declaration!
2022-01-10 14:29:36 -07:00
Behdad Esfahbod
394f772937
[map] Allow storing classes in the hashmap
...
Fixes https://github.com/harfbuzz/harfbuzz/issues/3293
The trick was to change the type of the invalid key/value to be non-class.
2021-11-19 11:49:23 -07:00
Behdad Esfahbod
b1cd0dce8e
[map] Add INVALID_KEY and INVALID_VALUE
2021-11-02 17:56:11 -06:00
Behdad Esfahbod
59d8f6c817
[map] Fix copy assignment operator
2021-11-02 10:33:53 -06:00
Behdad Esfahbod
943921cf0c
[meta] Use more std type_traits
2021-11-02 00:26:46 -06:00
Behdad Esfahbod
811f80a701
[algs] Use std::move instead of hb_move()
2021-11-02 00:17:54 -06:00
Behdad Esfahbod
4c6fd7cdb2
[map] Try moving items when resizing
2021-11-01 23:13:34 -06:00
Behdad Esfahbod
a28ea8d7f3
Simplify swap()
2021-11-01 22:50:54 -06:00
Behdad Esfahbod
94158316d9
[map] Add iterable constructor
2021-11-01 22:47:26 -06:00
Behdad Esfahbod
a03b9b14c9
[map] Add initializer_list and swap()
2021-11-01 22:45:11 -06:00
Behdad Esfahbod
c30f6834d0
[map] Add 5 methods
2021-11-01 22:29:14 -06:00
Behdad Esfahbod
d3e09bf465
[set] Make all operators null-safe again
...
Changed my mind.
Also for hb_map_clear().
Part of https://github.com/harfbuzz/harfbuzz/pull/3162
2021-08-24 10:31:49 -06:00
Garret Rieger
c08f1b8903
[map] fix incorrect population count in hash map.
...
If the same key was set twice the population was being incorrectly incremented.
2021-08-10 14:00:55 -06:00
Behdad Esfahbod
2337f0d047
Internally use hb_malloc/.../hb_free instead of malloc/.../free
...
Redefining those stock names as macros was conflicting with gcc 10
headers.
Fixes https://github.com/harfbuzz/harfbuzz/issues/3044
2021-07-08 10:54:09 -07:00
Behdad Esfahbod
a8f9f85a91
[map] Return success from ->set()
2021-03-29 18:13:22 -06:00
Behdad Esfahbod
2fbd34f89a
m[set/map] Add operator bool()
...
Probably should use in places..
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
2d39031f7b
[buffer/set/map] Move immutable check only to C API boundary
...
The immutable objects are a concept only enforced by the C API.
So move checks only to that region.
This does assume that the rest of the code is careful not getting
into these internal methods on immutable objects, which something
we do, but have no way of enforcing (currently).
.
2021-02-19 18:40:48 -07:00
Behdad Esfahbod
6a45df0a54
Fix -Wambiguous-reversed-operator warning
...
Fixes https://github.com/harfbuzz/harfbuzz/issues/2554
2020-07-08 18:17:40 -05:00
Ebrahim Byagowi
e541fb474c
minor, replace single hb_apply daggers with foreach
2020-06-21 10:31:39 +04:30
Behdad Esfahbod
a7df5a7bda
[hashmap] Minor
2020-04-24 08:16:03 -07:00
Ebrahim Byagowi
2dda6dd744
minor, tweak spacing
...
turn 8 spaces to tab, add space before Null/Crap
2020-04-20 16:18:29 +04:30
Garret Rieger
be5cdcdfa2
Store the hash value of a key in item_t in hb_map to reduce the number of hash computations.
2019-10-22 13:33:41 -07:00