chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] effectful short cut


From: F. Wittenberger
Subject: [Chicken-users] effectful short cut
Date: Wed, 10 Dec 2008 12:46:13 +0100

Hi all,

YMMV about that one.  I have several string comparisons, where the
compared strings might turn out to be eq? too.  Apparently often enough,
this patch saves almost 20% runtime for me.

/Jörg

Index: runtime.c
===================================================================
--- runtime.c   (Revision 12808)
+++ runtime.c   (Arbeitskopie)
@@ -4552,6 +4552,8 @@
   if(C_immediatep(y) || C_header_bits(y) != C_STRING_TYPE)
     barf(C_BAD_ARGUMENT_TYPE_ERROR, "string=?", y);
 
+  if( x == y ) return C_SCHEME_TRUE;
+
   n = C_header_size(x);
 
   return C_mk_bool(n == C_header_size(y) && !C_memcmp((char
*)C_data_pointer(x), (char *)C_data_pointer(y), n));
@@ -4562,6 +4564,8 @@
 {
   C_word n;
 
+  if( x == y ) return C_SCHEME_TRUE;
+
   n = C_header_size(x);
   return C_mk_bool(n == C_header_size(y) && !C_memcmp((char
*)C_data_pointer(x), (char *)C_data_pointer(y), n));
 }
@@ -4578,6 +4582,8 @@
   if(C_immediatep(y) || C_header_bits(y) != C_STRING_TYPE)
     barf(C_BAD_ARGUMENT_TYPE_ERROR, "string-ci=?", y);
 
+  if( x == y ) return C_SCHEME_TRUE;
+
   n = C_header_size(x);
 
   if(n != C_header_size(y)) return C_SCHEME_FALSE;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]