st refactor add_packed_direct a bit
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34313 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
638f696b6e
commit
9ed8c1f15e
21
st.c
21
st.c
@ -469,10 +469,9 @@ unpack_entries(register st_table *table)
|
|||||||
*table = tmp_table;
|
*table = tmp_table;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
add_packed_direct(st_table *table, st_data_t key, st_data_t value)
|
add_packed_direct(st_table *table, st_data_t key, st_data_t value)
|
||||||
{
|
{
|
||||||
int res = 1;
|
|
||||||
if (table->num_entries < MAX_PACKED_NUMHASH) {
|
if (table->num_entries < MAX_PACKED_NUMHASH) {
|
||||||
st_index_t i = table->num_entries++;
|
st_index_t i = table->num_entries++;
|
||||||
PKEY_SET(table, i, key);
|
PKEY_SET(table, i, key);
|
||||||
@ -480,9 +479,8 @@ add_packed_direct(st_table *table, st_data_t key, st_data_t value)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
unpack_entries(table);
|
unpack_entries(table);
|
||||||
res = 0;
|
add_direct(table, key, value, key, key % table->num_bins);
|
||||||
}
|
}
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -498,9 +496,8 @@ st_insert(register st_table *table, register st_data_t key, st_data_t value)
|
|||||||
PVAL_SET(table, i, value);
|
PVAL_SET(table, i, value);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (add_packed_direct(table, key, value)) {
|
add_packed_direct(table, key, value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_val = do_hash(key, table);
|
hash_val = do_hash(key, table);
|
||||||
@ -530,9 +527,8 @@ st_insert2(register st_table *table, register st_data_t key, st_data_t value,
|
|||||||
PVAL_SET(table, i, value);
|
PVAL_SET(table, i, value);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (add_packed_direct(table, key, value)) {
|
add_packed_direct(table, key, value);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_val = do_hash(key, table);
|
hash_val = do_hash(key, table);
|
||||||
@ -556,9 +552,8 @@ st_add_direct(st_table *table, st_data_t key, st_data_t value)
|
|||||||
st_index_t hash_val, bin_pos;
|
st_index_t hash_val, bin_pos;
|
||||||
|
|
||||||
if (table->entries_packed) {
|
if (table->entries_packed) {
|
||||||
if (add_packed_direct(table, key, value)) {
|
add_packed_direct(table, key, value);
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_val = do_hash(key, table);
|
hash_val = do_hash(key, table);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user