1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

date: use del_hash to extract an element destructively

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67409 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2019-04-02 03:48:58 +00:00
parent 1ad6dde9da
commit e8f8cf111f
3 changed files with 5 additions and 11 deletions

View file

@ -3692,7 +3692,7 @@ rt_rewrite_frags(VALUE hash)
{ {
VALUE seconds; VALUE seconds;
seconds = ref_hash("seconds"); seconds = del_hash("seconds");
if (!NIL_P(seconds)) { if (!NIL_P(seconds)) {
VALUE offset, d, h, min, s, fr; VALUE offset, d, h, min, s, fr;
@ -3717,7 +3717,6 @@ rt_rewrite_frags(VALUE hash)
set_hash("min", min); set_hash("min", min);
set_hash("sec", s); set_hash("sec", s);
set_hash("sec_fraction", fr); set_hash("sec_fraction", fr);
del_hash("seconds");
} }
return hash; return hash;
} }

View file

@ -2177,7 +2177,7 @@ date__parse(VALUE str, VALUE comp)
#endif #endif
{ {
if (RTEST(ref_hash("_bc"))) { if (RTEST(del_hash("_bc"))) {
VALUE y; VALUE y;
y = ref_hash("cwyear"); y = ref_hash("cwyear");
@ -2192,7 +2192,7 @@ date__parse(VALUE str, VALUE comp)
} }
} }
if (RTEST(ref_hash("_comp"))) { if (RTEST(del_hash("_comp"))) {
VALUE y; VALUE y;
y = ref_hash("cwyear"); y = ref_hash("cwyear");
@ -2215,9 +2215,6 @@ date__parse(VALUE str, VALUE comp)
} }
del_hash("_bc");
del_hash("_comp");
{ {
VALUE zone = ref_hash("zone"); VALUE zone = ref_hash("zone");
if (!NIL_P(zone) && NIL_P(ref_hash("offset"))) if (!NIL_P(zone) && NIL_P(ref_hash("offset")))

View file

@ -669,7 +669,7 @@ date__strptime(const char *str, size_t slen,
if (fail_p()) if (fail_p())
return Qnil; return Qnil;
cent = ref_hash("_cent"); cent = del_hash("_cent");
if (!NIL_P(cent)) { if (!NIL_P(cent)) {
VALUE year; VALUE year;
@ -679,10 +679,9 @@ date__strptime(const char *str, size_t slen,
year = ref_hash("year"); year = ref_hash("year");
if (!NIL_P(year)) if (!NIL_P(year))
set_hash("year", f_add(year, f_mul(cent, INT2FIX(100)))); set_hash("year", f_add(year, f_mul(cent, INT2FIX(100))));
del_hash("_cent");
} }
merid = ref_hash("_merid"); merid = del_hash("_merid");
if (!NIL_P(merid)) { if (!NIL_P(merid)) {
VALUE hour; VALUE hour;
@ -691,7 +690,6 @@ date__strptime(const char *str, size_t slen,
hour = f_mod(hour, INT2FIX(12)); hour = f_mod(hour, INT2FIX(12));
set_hash("hour", f_add(hour, merid)); set_hash("hour", f_add(hour, merid));
} }
del_hash("_merid");
} }
return hash; return hash;