Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

Commit

Permalink
Hoist assignment into the for loop.
Browse files Browse the repository at this point in the history
  • Loading branch information
szegedi committed Mar 24, 2011
1 parent ac27e15 commit 3920706
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions st.c
Expand Up @@ -481,14 +481,13 @@ st_foreach_map(table, map_key_func, map_value_func)
int i; int i;


for(i = 0; i < table->num_bins; i++) { for(i = 0; i < table->num_bins; i++) {
for(ptr = table->bins[i]; ptr != 0;) { for(ptr = table->bins[i]; ptr != 0; ptr = ptr->next) {
new_key = (*map_key_func)(ptr->key); new_key = (*map_key_func)(ptr->key);
if(new_key != ptr->key && table->type->compare(new_key, ptr->key)) { if(new_key != ptr->key && table->type->compare(new_key, ptr->key)) {
rb_bug("Key replaced with non-equal key"); rb_bug("Key replaced with non-equal key");
} }
ptr->key = new_key; ptr->key = new_key;
ptr->record = (*map_value_func)(ptr->record); ptr->record = (*map_value_func)(ptr->record);
ptr = ptr->next;
} }
} }
} }
Expand Down

0 comments on commit 3920706

Please sign in to comment.