Hi, 
as I looked to compare_string I discovered that it could be
optimized. This speeds up case when strings are equal but we must check
padding where checking it byte by byte is suboptimal.

Ondra

2013-03-27  Ondřej Bílka  <nel...@seznam.cz>

        * libgfortran/intrinsics/string_intrinsics_inc.c (compare_string): 
Optimize.

diff --git a/libgfortran/intrinsics/string_intrinsics_inc.c 
b/libgfortran/intrinsics/string_intrinsics_inc.c
index a1f86b5..9eb0613 100644
--- a/libgfortran/intrinsics/string_intrinsics_inc.c
+++ b/libgfortran/intrinsics/string_intrinsics_inc.c
@@ -107,16 +107,15 @@ compare_string (gfc_charlen_type len1, const CHARTYPE *s1,
       res = 1;
     }
 
-  while (len--)
+       s = memchr (s, ' ', len);
+       if (!s)
+               return 0;
+  if (*s != ' ')
     {
-      if (*s != ' ')
-        {
-          if (*s > ' ')
-            return res;
-          else
-            return -res;
-        }
-      s++;
+      if (*s > ' ')
+        return res;
+      else
+        return -res;
     }
 
   return 0;

Reply via email to