[前][次][番号順一覧][スレッド一覧]

ruby-changes:55203

From: nobu <ko1@a...>
Date: Tue, 2 Apr 2019 12:49:04 +0900 (JST)
Subject: [ruby-changes:55203] nobu:r67409 (trunk): date: use del_hash to extract an element destructively

nobu	2019-04-02 12:48:58 +0900 (Tue, 02 Apr 2019)

  New Revision: 67409

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=67409

  Log:
    date: use del_hash to extract an element destructively

  Modified files:
    trunk/ext/date/date_core.c
    trunk/ext/date/date_parse.c
    trunk/ext/date/date_strptime.c
Index: ext/date/date_strptime.c
===================================================================
--- ext/date/date_strptime.c	(revision 67408)
+++ ext/date/date_strptime.c	(revision 67409)
@@ -669,7 +669,7 @@ date__strptime(const char *str, size_t s https://github.com/ruby/ruby/blob/trunk/ext/date/date_strptime.c#L669
     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 s https://github.com/ruby/ruby/blob/trunk/ext/date/date_strptime.c#L679
 	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 s https://github.com/ruby/ruby/blob/trunk/ext/date/date_strptime.c#L690
 	    hour = f_mod(hour, INT2FIX(12));
 	    set_hash("hour", f_add(hour, merid));
 	}
-	del_hash("_merid");
     }
 
     return hash;
Index: ext/date/date_core.c
===================================================================
--- ext/date/date_core.c	(revision 67408)
+++ ext/date/date_core.c	(revision 67409)
@@ -3692,7 +3692,7 @@ rt_rewrite_frags(VALUE hash) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3692
 {
     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) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L3717
 	set_hash("min", min);
 	set_hash("sec", s);
 	set_hash("sec_fraction", fr);
-	del_hash("seconds");
     }
     return hash;
 }
Index: ext/date/date_parse.c
===================================================================
--- ext/date/date_parse.c	(revision 67408)
+++ ext/date/date_parse.c	(revision 67409)
@@ -2177,7 +2177,7 @@ date__parse(VALUE str, VALUE comp) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L2177
 #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) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L2192
 	    }
 	}
 
-	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) https://github.com/ruby/ruby/blob/trunk/ext/date/date_parse.c#L2215
 
     }
 
-    del_hash("_bc");
-    del_hash("_comp");
-
     {
 	VALUE zone = ref_hash("zone");
 	if (!NIL_P(zone) && NIL_P(ref_hash("offset")))

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]