Skip to content

Commit

Permalink
[map] Optimize storage
Browse files Browse the repository at this point in the history
Such that population isn't a bitfield as we access it often.
  • Loading branch information
behdad committed Nov 13, 2023
1 parent 894a1f7 commit 6a3ca37
Showing 1 changed file with 6 additions and 9 deletions.
15 changes: 6 additions & 9 deletions src/hb-map.hh
Original file line number Diff line number Diff line change
Expand Up @@ -137,37 +137,34 @@ struct hb_hashmap_t
};

hb_object_header_t header;
unsigned int successful : 1; /* Allocations successful */
unsigned int population : 31; /* Not including tombstones. */
bool successful; /* Allocations successful */
unsigned short max_chain_length;
unsigned int population; /* Not including tombstones. */
unsigned int occupancy; /* Including tombstones. */
unsigned int mask;
unsigned int prime;
unsigned int max_chain_length;
item_t *items;

friend void swap (hb_hashmap_t& a, hb_hashmap_t& b)
{
if (unlikely (!a.successful || !b.successful))
return;
unsigned tmp = a.population;
a.population = b.population;
b.population = tmp;
//hb_swap (a.population, b.population);
hb_swap (a.max_chain_length, b.max_chain_length);
hb_swap (a.population, b.population);
hb_swap (a.occupancy, b.occupancy);
hb_swap (a.mask, b.mask);
hb_swap (a.prime, b.prime);
hb_swap (a.max_chain_length, b.max_chain_length);
hb_swap (a.items, b.items);
}
void init ()
{
hb_object_init (this);

successful = true;
max_chain_length = 0;
population = occupancy = 0;
mask = 0;
prime = 0;
max_chain_length = 0;
items = nullptr;
}
void fini ()
Expand Down

0 comments on commit 6a3ca37

Please sign in to comment.