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

ruby-changes:29026

From: tadf <ko1@a...>
Date: Wed, 5 Jun 2013 07:19:15 +0900 (JST)
Subject: [ruby-changes:29026] tadf:r41078 (trunk): * ext/date/date_core.c (d_lite_cmp, d_lite_equal): simplified.

tadf	2013-06-05 07:18:12 +0900 (Wed, 05 Jun 2013)

  New Revision: 41078

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41078

  Log:
    * ext/date/date_core.c (d_lite_cmp, d_lite_equal): simplified.

  Modified files:
    trunk/ChangeLog
    trunk/ext/date/date_core.c

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 41077)
+++ ChangeLog	(revision 41078)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Wed Jun  5 07:14:18 2013  Tadayoshi Funaba  <tadf@d...>
+
+	* ext/date/date_core.c (d_lite_cmp, d_lite_equal): simplified.
+
 Wed Jun  5 07:07:01 2013  Tadayoshi Funaba  <tadf@d...>
 
 	* ext/date/date_core.c: fixed a bug [ruby-core:55295].  reported
Index: ext/date/date_core.c
===================================================================
--- ext/date/date_core.c	(revision 41077)
+++ ext/date/date_core.c	(revision 41078)
@@ -6285,8 +6285,7 @@ d_lite_cmp(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6285
 	      m_gregorian_p(adat) == m_gregorian_p(bdat)))
 	    return cmp_dd(self, other);
 
-	if (have_jd_p(adat) &&
-	    have_jd_p(bdat)) {
+	{
 	    VALUE a_nth, b_nth;
 	    int a_jd, b_jd;
 
@@ -6314,76 +6313,6 @@ d_lite_cmp(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6313
 		return INT2FIX(1);
 	    }
 	}
-	else {
-#ifndef USE_PACK
-	    VALUE a_nth, b_nth;
-	    int a_year, b_year,
-		a_mon, b_mon,
-		a_mday, b_mday;
-#else
-	    VALUE a_nth, b_nth;
-	    int a_year, b_year,
-		a_pd, b_pd;
-#endif
-
-	    m_canonicalize_jd(adat);
-	    m_canonicalize_jd(bdat);
-	    a_nth = m_nth(adat);
-	    b_nth = m_nth(bdat);
-	    if (f_eqeq_p(a_nth, b_nth)) {
-		a_year = m_year(adat);
-		b_year = m_year(bdat);
-		if (a_year == b_year) {
-#ifndef USE_PACK
-		    a_mon = m_mon(adat);
-		    b_mon = m_mon(bdat);
-		    if (a_mon == b_mon) {
-			a_mday = m_mday(adat);
-			b_mday = m_mday(bdat);
-			if (a_mday == b_mday) {
-			    return INT2FIX(0);
-			}
-			else if (a_mday < b_mday) {
-			    return INT2FIX(-1);
-			}
-			else {
-			    return INT2FIX(1);
-			}
-		    }
-		    else if (a_mon < b_mon) {
-			return INT2FIX(-1);
-		    }
-		    else {
-			return INT2FIX(1);
-		    }
-#else
-		    a_pd = m_pc(adat);
-		    b_pd = m_pc(bdat);
-		    if (a_pd == b_pd) {
-			return INT2FIX(0);
-		    }
-		    else if (a_pd < b_pd) {
-			return INT2FIX(-1);
-		    }
-		    else {
-			return INT2FIX(1);
-		    }
-#endif
-		}
-		else if (a_year < b_year) {
-		    return INT2FIX(-1);
-		}
-		else {
-		    return INT2FIX(1);
-		}
-	    }
-	    else if (f_lt_p(a_nth, b_nth)) {
-		return INT2FIX(-1);
-	    }
-	    else {
-		return INT2FIX(1);
-	    }
-	}
     }
 }
 
@@ -6428,8 +6357,7 @@ d_lite_equal(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6357
 	if (!(m_gregorian_p(adat) == m_gregorian_p(bdat)))
 	    return equal_gen(self, other);
 
-	if (have_jd_p(adat) &&
-	    have_jd_p(bdat)) {
+	{
 	    VALUE a_nth, b_nth;
 	    int a_jd, b_jd;
 
@@ -6444,47 +6372,6 @@ d_lite_equal(VALUE self, VALUE other) https://github.com/ruby/ruby/blob/trunk/ext/date/date_core.c#L6372
 		return Qtrue;
 	    return Qfalse;
 	}
-	else {
-#ifndef USE_PACK
-	    VALUE a_nth, b_nth;
-	    int a_year, b_year,
-		a_mon, b_mon,
-		a_mday, b_mday;
-#else
-	    VALUE a_nth, b_nth;
-	    int a_year, b_year,
-		a_pd, b_pd;
-#endif
-
-	    m_canonicalize_jd(adat);
-	    m_canonicalize_jd(bdat);
-	    a_nth = m_nth(adat);
-	    b_nth = m_nth(bdat);
-	    if (f_eqeq_p(a_nth, b_nth)) {
-		a_year = m_year(adat);
-		b_year = m_year(bdat);
-		if (a_year == b_year) {
-#ifndef USE_PACK
-		    a_mon = m_mon(adat);
-		    b_mon = m_mon(bdat);
-		    if (a_mon == b_mon) {
-			a_mday = m_mday(adat);
-			b_mday = m_mday(bdat);
-			if (a_mday == b_mday)
-			    return Qtrue;
-		    }
-#else
-		    /* mon and mday only */
-		    a_pd = (m_pc(adat) >> MDAY_SHIFT);
-		    b_pd = (m_pc(bdat) >> MDAY_SHIFT);
-		    if (a_pd == b_pd) {
-			return Qtrue;
-		    }
-#endif
-		}
-	    }
-	    return Qfalse;
-	}
     }
 }
 

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

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