[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Optimization svn_path_compare_paths

From: Sander Striker <striker_at_apache.org>
Date: 2001-09-06 02:14:45 CEST

Hi all,

The log says it all.

Sander

---
Log:
* path.c (svn_path_compare_paths): - Optimize by eliminating a call to
strncmp
                                   - Remove unneeded else statements
Index: trunk/subversion/libsvn_subr/path.c
===================================================================
--- trunk/subversion/libsvn_subr/SVN/text-base/path.c   Thu Sep  6 01:14:16
2001
+++ trunk/subversion/libsvn_subr/path.c Thu Sep  6 02:00:37 2001
@@ -223,12 +223,17 @@
   if ((path1->len == path2->len) && (i >= min_len))
     return 0;     /* the paths are the same */
-  else if (path1->data[i] == dirsep)
+
+  if (path1->data[i] == dirsep)
     return 1;     /* path1 child of path2, parent always comes before child
*/
-  else if (path2->data[i] == dirsep)
+
+  if (path2->data[i] == dirsep)
     return -1;    /* path2 child of path1, parent always comes before child
*/
-  else
-    return strncmp (path1->data + i, path2->data + i, (min_len - i));
+
+  /* Common prefix was skipped above, next character is
+   * compared to determine order
+   */
+  return path1->data[i] < path2->data[i] ? -1 : 1;
 }
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Oct 21 14:36:40 2006

This is an archived mail posted to the Subversion Dev mailing list.