[uim-commit] r1251 - branches/r5rs/sigscheme

yamaken at freedesktop.org yamaken at freedesktop.org
Sun Aug 21 09:41:58 EST 2005


Author: yamaken
Date: 2005-08-20 16:41:56 -0700 (Sat, 20 Aug 2005)
New Revision: 1251

Modified:
   branches/r5rs/sigscheme/operations.c
Log:
* sigscheme/operations.c
  - (ScmOp_eqvp, ScmOp_eqp, ScmOp_equalp): Optimize. eq? is an
    identicality predicate rather than a value comparator


Modified: branches/r5rs/sigscheme/operations.c
===================================================================
--- branches/r5rs/sigscheme/operations.c	2005-08-20 23:04:20 UTC (rev 1250)
+++ branches/r5rs/sigscheme/operations.c	2005-08-20 23:41:56 UTC (rev 1251)
@@ -71,8 +71,13 @@
 ==============================================================================*/
 ScmObj ScmOp_eqvp(ScmObj obj1, ScmObj obj2)
 {
-    enum ScmObjType type = (enum ScmObjType)SCM_GETTYPE(obj1);
+    enum ScmObjType type;
 
+    if (SCM_EQ(obj1, obj2))
+        return SCM_TRUE;
+
+    type = (enum ScmObjType)SCM_GETTYPE(obj1);
+
     /* different type */
     if (type != SCM_GETTYPE(obj2))
         return SCM_FALSE;
@@ -86,13 +91,6 @@
                 return SCM_TRUE;
             }
             break;
-        case ScmSymbol:
-            /* symbols which have same name */
-            if (strcmp(SCM_SYMBOL_NAME(obj1), SCM_SYMBOL_NAME(obj2)) == 0)
-            {
-                return SCM_TRUE;
-            }
-            break;
         case ScmChar:
             /* chars and are the same character according to the char=? */
             if (EQ(ScmOp_char_equal(obj1, obj2), SCM_TRUE))
@@ -100,6 +98,7 @@
                 return SCM_TRUE;
             }
             break;
+        case ScmSymbol:  /* equivalent symbols must already be true on eq? */
         case ScmCons:
         case ScmVector:
         case ScmString:
@@ -107,23 +106,7 @@
         case ScmClosure:
 	case ScmPort:
 	case ScmContinuation:
-            if (EQ(obj1, obj2))
-            {
-                return SCM_TRUE;
-            }
-            break;
         case ScmEtc:
-            /* obj1 and obj2 are both #t or both #f */
-            if (((EQ(obj1, SCM_TRUE) && EQ(obj2, SCM_TRUE)))
-                || (EQ(obj1, SCM_FALSE) && EQ(obj2, SCM_FALSE)))
-            {
-                return SCM_TRUE;
-            }
-            /* both obj1 and obj2 are the empty list */
-            if (SCM_NULLP(obj1) && SCM_NULLP(obj2))
-            {
-                return SCM_TRUE;
-            }
             break;
         case ScmFreeCell:
             SigScm_Error("eqv? : cannnot compare freecell, gc broken?\n");
@@ -131,10 +114,7 @@
 	case ScmCPointer:
 	case ScmCFuncPointer:
 	case ScmValuePacket:
-	    if (EQ(obj1, obj2))
-	    {
-		return SCM_TRUE;
-	    }
+            break;
     }
 
     return SCM_FALSE;
@@ -142,14 +122,19 @@
 
 ScmObj ScmOp_eqp(ScmObj obj1, ScmObj obj2)
 {
-    return ScmOp_eqvp(obj1, obj2);
+    return (SCM_EQ(obj1, obj2)) ? SCM_TRUE : SCM_FALSE;
 }
 
 ScmObj ScmOp_equalp(ScmObj obj1, ScmObj obj2)
 {
     int  i = 0;
-    enum ScmObjType type = (enum ScmObjType)SCM_GETTYPE(obj1);
+    enum ScmObjType type;
 
+    if (SCM_EQ(obj1, obj2))
+        return SCM_TRUE;
+
+    type = (enum ScmObjType)SCM_GETTYPE(obj1);
+
     /* different type */
     if (type != SCM_GETTYPE(obj2))
         return SCM_FALSE;
@@ -163,13 +148,6 @@
                 return SCM_TRUE;
             }
             break;
-        case ScmSymbol:
-            /* symbols which have same name */
-            if (strcmp(SCM_SYMBOL_NAME(obj1), SCM_SYMBOL_NAME(obj2)) == 0)
-            {
-                return SCM_TRUE;
-            }
-            break;
         case ScmChar:
             /* chars and are the same character according to the char=? */
             if (EQ(ScmOp_char_equal(obj1, obj2), SCM_TRUE))
@@ -230,9 +208,8 @@
                 return SCM_UNSPECIFIED;
             }
             break;
+        case ScmSymbol:  /* equivalent symbols must already be true on eq? */
         case ScmEtc:
-	    if (EQ(obj1, obj2))
-		return SCM_TRUE;
             break;
         case ScmFreeCell:
             SigScm_Error("equal? : cannnot compare freecell, gc broken?\n");



More information about the uim-commit mailing list