diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-02 03:48:58 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-02 03:48:58 +0000 |
commit | e8f8cf111fc1cd6ee7a00b692ba208bd1c7ce539 (patch) | |
tree | 4823a53e50bae0a70903c7d46192c30458cf644c | |
parent | 1ad6dde9da48149f1998eb5b85916165867c2368 (diff) | |
download | ruby-e8f8cf111fc1cd6ee7a00b692ba208bd1c7ce539.tar.gz |
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
-rw-r--r-- | ext/date/date_core.c | 3 | ||||
-rw-r--r-- | ext/date/date_parse.c | 7 | ||||
-rw-r--r-- | ext/date/date_strptime.c | 6 |
3 files changed, 5 insertions, 11 deletions
diff --git a/ext/date/date_core.c b/ext/date/date_core.c index 49027e92b1..88be90b6bc 100644 --- a/ext/date/date_core.c +++ b/ext/date/date_core.c @@ -3692,7 +3692,7 @@ rt_rewrite_frags(VALUE hash) { VALUE seconds; - seconds = ref_hash("seconds"); + seconds = del_hash("seconds"); if (!NIL_P(seconds)) { VALUE offset, d, h, min, s, fr; @@ -3717,7 +3717,6 @@ rt_rewrite_frags(VALUE hash) set_hash("min", min); set_hash("sec", s); set_hash("sec_fraction", fr); - del_hash("seconds"); } return hash; } diff --git a/ext/date/date_parse.c b/ext/date/date_parse.c index fcda847bd8..3237fb7f63 100644 --- a/ext/date/date_parse.c +++ b/ext/date/date_parse.c @@ -2177,7 +2177,7 @@ date__parse(VALUE str, VALUE comp) #endif { - if (RTEST(ref_hash("_bc"))) { + if (RTEST(del_hash("_bc"))) { VALUE y; 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; 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"); if (!NIL_P(zone) && NIL_P(ref_hash("offset"))) diff --git a/ext/date/date_strptime.c b/ext/date/date_strptime.c index 4383eb6fa1..26d9fd11bf 100644 --- a/ext/date/date_strptime.c +++ b/ext/date/date_strptime.c @@ -669,7 +669,7 @@ date__strptime(const char *str, size_t slen, if (fail_p()) return Qnil; - cent = ref_hash("_cent"); + cent = del_hash("_cent"); if (!NIL_P(cent)) { VALUE year; @@ -679,10 +679,9 @@ date__strptime(const char *str, size_t slen, year = ref_hash("year"); if (!NIL_P(year)) 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)) { VALUE hour; @@ -691,7 +690,6 @@ date__strptime(const char *str, size_t slen, hour = f_mod(hour, INT2FIX(12)); set_hash("hour", f_add(hour, merid)); } - del_hash("_merid"); } return hash; |