aboutsummaryrefslogtreecommitdiff
path: root/src/string_map.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2023-01-14 12:58:45 +0000
committergingerBill <bill@gingerbill.org>2023-01-14 12:58:45 +0000
commit868aa4c14ab6c63b9b797f4a8178c73b69897711 (patch)
tree311c9f807830cb32f7102c49b22053da7087a883 /src/string_map.cpp
parent1ab90de4931f07ea61b1195de602f282a853568b (diff)
Minor changes to `StringMap` allocation
Diffstat (limited to 'src/string_map.cpp')
-rw-r--r--src/string_map.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/string_map.cpp b/src/string_map.cpp
index 3bd08d09f..067adef28 100644
--- a/src/string_map.cpp
+++ b/src/string_map.cpp
@@ -1,5 +1,11 @@
GB_STATIC_ASSERT(sizeof(MapIndex) == sizeof(u32));
+enum {
+ STRING_MAP_CACHE_LINE_SIZE_POW = 6,
+ STRING_MAP_CACHE_LINE_SIZE = 1<<STRING_MAP_CACHE_LINE_SIZE_POW,
+ STRING_MAP_CACHE_LINE_MASK = STRING_MAP_CACHE_LINE_SIZE-1,
+};
+
struct StringHashKey {
u32 hash;
String string;
@@ -79,13 +85,13 @@ gb_internal gb_inline void string_map_destroy(StringMap<T> *h) {
template <typename T>
gb_internal void string_map__resize_hashes(StringMap<T> *h, usize count) {
- h->hashes_count = cast(u32)resize_array_raw(&h->hashes, string_map_allocator(), h->hashes_count, count);
+ h->hashes_count = cast(u32)resize_array_raw(&h->hashes, string_map_allocator(), h->hashes_count, count, STRING_MAP_CACHE_LINE_SIZE);
}
template <typename T>
gb_internal void string_map__reserve_entries(StringMap<T> *h, usize capacity) {
- h->entries_capacity = cast(u32)resize_array_raw(&h->entries, string_map_allocator(), h->entries_capacity, capacity);
+ h->entries_capacity = cast(u32)resize_array_raw(&h->entries, string_map_allocator(), h->entries_capacity, capacity, STRING_MAP_CACHE_LINE_SIZE);
}