mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
hash.c: dry up code
* hash.c (rb_hash_update_{block,func}_callback): dry up hash update callback code. [Fix GH-1338] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@54810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
0c4466abba
commit
a19b53aeab
2 changed files with 7 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Thu Apr 28 17:03:17 2016 Nicholas Maccharoli <nmaccharoli@gmail.com>
|
||||||
|
|
||||||
|
* hash.c (rb_hash_update_{block,func}_callback): dry up hash
|
||||||
|
update callback code. [Fix GH-1338]
|
||||||
|
|
||||||
Thu Apr 28 16:52:05 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
Thu Apr 28 16:52:05 2016 NARUSE, Yui <naruse@ruby-lang.org>
|
||||||
|
|
||||||
* re.c (rb_reg_prepare_enc): use rb_enc_asciicompat(enc) instead of
|
* re.c (rb_reg_prepare_enc): use rb_enc_asciicompat(enc) instead of
|
||||||
|
|
6
hash.c
6
hash.c
|
@ -2291,12 +2291,11 @@ rb_hash_update_block_callback(st_data_t *key, st_data_t *value, struct update_ar
|
||||||
if (existing) {
|
if (existing) {
|
||||||
newvalue = rb_yield_values(3, (VALUE)*key, (VALUE)*value, newvalue);
|
newvalue = rb_yield_values(3, (VALUE)*key, (VALUE)*value, newvalue);
|
||||||
arg->old_value = *value;
|
arg->old_value = *value;
|
||||||
arg->new_value = newvalue;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg->new_key = *key;
|
arg->new_key = *key;
|
||||||
arg->new_value = newvalue;
|
|
||||||
}
|
}
|
||||||
|
arg->new_value = newvalue;
|
||||||
*value = newvalue;
|
*value = newvalue;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@ -2362,12 +2361,11 @@ rb_hash_update_func_callback(st_data_t *key, st_data_t *value, struct update_arg
|
||||||
if (existing) {
|
if (existing) {
|
||||||
newvalue = (*uf_arg->func)((VALUE)*key, (VALUE)*value, newvalue);
|
newvalue = (*uf_arg->func)((VALUE)*key, (VALUE)*value, newvalue);
|
||||||
arg->old_value = *value;
|
arg->old_value = *value;
|
||||||
arg->new_value = newvalue;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
arg->new_key = *key;
|
arg->new_key = *key;
|
||||||
arg->new_value = newvalue;
|
|
||||||
}
|
}
|
||||||
|
arg->new_value = newvalue;
|
||||||
*value = newvalue;
|
*value = newvalue;
|
||||||
return ST_CONTINUE;
|
return ST_CONTINUE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue