From c208db0752461b055b4b672ae45ba0489263ef08 Mon Sep 17 00:00:00 2001 From: Joshua Haberman Date: Wed, 8 Jul 2009 11:39:07 -0700 Subject: Pre-compute the hash table mask to avoid doing it in the critical path. --- upb_table.c | 1 + 1 file changed, 1 insertion(+) (limited to 'upb_table.c') diff --git a/upb_table.c b/upb_table.c index 03fab2f..3bbc7f7 100644 --- a/upb_table.c +++ b/upb_table.c @@ -30,6 +30,7 @@ void upb_table_init(struct upb_table *t, uint32_t size, uint16_t entry_size) t->size_lg2 = 1; while(size >>= 1) t->size_lg2++; size_t bytes = upb_table_size(t) * t->entry_size; + t->mask = upb_table_size(t) - 1; t->entries = malloc(bytes); memset(t->entries, 0, bytes); /* Both tables consider 0's an empty entry. */ } -- cgit v1.2.3