Skip to content

Commit 111cf33

Browse files
committed
More small optimizations
1 parent 3c7e926 commit 111cf33

File tree

1 file changed

+17
-28
lines changed

1 file changed

+17
-28
lines changed

st.c

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -939,29 +939,24 @@ find_table_entry_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
939939
static st_index_t
940940
find_table_bin_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
941941
{
942-
int eq_p, rebuilt_p;
943-
st_index_t ind;
944-
#ifdef QUADRATIC_PROBE
945-
st_index_t d;
946-
#else
947-
st_index_t peterb;
948-
#endif
949-
st_index_t bin;
950-
st_table_entry *entries = tab->entries;
951-
952942
st_assert(tab != NULL);
953943
st_assert(tab->bins != NULL);
954-
ind = hash_bin(hash_value, tab);
944+
945+
unsigned short int eq_p, rebuilt_p;
946+
st_index_t ind = hash_bin(hash_value, tab);
947+
st_index_t bin;
955948
#ifdef QUADRATIC_PROBE
956-
d = 1;
949+
st_index_t d = 1;
957950
#else
958-
peterb = hash_value;
951+
st_index_t peterb = hash_value;
959952
#endif
953+
960954
FOUND_BIN;
955+
961956
for (;;) {
962957
bin = get_bin(tab->bins, get_size_ind(tab), ind);
963958
if (! EMPTY_OR_DELETED_BIN_P(bin)) {
964-
DO_PTR_EQUAL_CHECK(tab, &entries[bin - ENTRY_BASE], hash_value, key, eq_p, rebuilt_p);
959+
DO_PTR_EQUAL_CHECK(tab, &tab->entries[bin - ENTRY_BASE], hash_value, key, eq_p, rebuilt_p);
965960
if (EXPECT(rebuilt_p, 0))
966961
return REBUILT_TABLE_BIN_IND;
967962
if (eq_p)
@@ -985,29 +980,23 @@ find_table_bin_ind(st_table *tab, st_hash_t hash_value, st_data_t key)
985980
static st_index_t
986981
find_table_bin_ind_direct(st_table *tab, st_hash_t hash_value, st_data_t key)
987982
{
988-
st_index_t ind;
989-
#ifdef QUADRATIC_PROBE
990-
st_index_t d;
991-
#else
992-
st_index_t peterb;
993-
#endif
994-
st_index_t bin;
995-
st_table_entry *entries = tab->entries;
996-
997983
st_assert(tab != NULL);
998984
st_assert(tab->bins != NULL);
999-
ind = hash_bin(hash_value, tab);
985+
986+
st_index_t ind = hash_bin(hash_value, tab);;
987+
st_index_t bin;
1000988
#ifdef QUADRATIC_PROBE
1001-
d = 1;
989+
st_index_t d = 1;
1002990
#else
1003-
peterb = hash_value;
991+
st_index_t peterb = hash_value;
1004992
#endif
993+
1005994
FOUND_BIN;
1006995
for (;;) {
1007996
bin = get_bin(tab->bins, get_size_ind(tab), ind);
1008997
if (EMPTY_OR_DELETED_BIN_P(bin))
1009998
return ind;
1010-
st_assert (entries[bin - ENTRY_BASE].hash != hash_value);
999+
st_assert (tab->entries[bin - ENTRY_BASE].hash != hash_value);
10111000
#ifdef QUADRATIC_PROBE
10121001
ind = hash_bin(ind + d, tab);
10131002
d++;
@@ -1031,7 +1020,7 @@ static st_index_t
10311020
find_table_bin_ptr_and_reserve(st_table *tab, st_hash_t *hash_value,
10321021
st_data_t key, st_index_t *bin_ind)
10331022
{
1034-
int eq_p, rebuilt_p;
1023+
unsigned short int eq_p, rebuilt_p;
10351024
st_index_t ind;
10361025
st_hash_t curr_hash_value = *hash_value;
10371026
#ifdef QUADRATIC_PROBE

0 commit comments

Comments
 (0)