You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by jc...@apache.org on 2011/01/22 22:11:30 UTC

svn commit: r1062275 - /subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c

Author: jcorvel
Date: Sat Jan 22 21:11:29 2011
New Revision: 1062275

URL: http://svn.apache.org/viewvc?rev=1062275&view=rev
Log:
On the diff-optimizations-bytes branch:

As a small extra optimization, count lines in a local variable during prefix
scanning.

* subversion/libsvn_diff/diff_file.c
  (find_identical_prefix): Use a local variable to count the number of lines,
   to make it slightly more efficient.

Modified:
    subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c

Modified: subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c
URL: http://svn.apache.org/viewvc/subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c?rev=1062275&r1=1062274&r2=1062275&view=diff
==============================================================================
--- subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c (original)
+++ subversion/branches/diff-optimizations-bytes/subversion/libsvn_diff/diff_file.c Sat Jan 22 21:11:29 2011
@@ -390,9 +390,9 @@ find_identical_prefix(svn_boolean_t *rea
 {
   svn_boolean_t had_cr = FALSE;
   svn_boolean_t is_match;
+  apr_off_t lines = 0;
   apr_size_t i;
 
-  *prefix_lines = 0;
   for (i = 1, is_match = TRUE; i < file_len; i++)
     is_match = is_match && *file[0].curp == *file[i].curp;
   while (is_match)
@@ -402,12 +402,12 @@ find_identical_prefix(svn_boolean_t *rea
       /* check for eol, and count */
       if (*file[0].curp == '\r')
         {
-          (*prefix_lines)++;
+          lines++;
           had_cr = TRUE;
         }
       else if (*file[0].curp == '\n' && !had_cr)
         {
-          (*prefix_lines)++;
+          lines++;
         }
       else 
         {
@@ -429,7 +429,7 @@ find_identical_prefix(svn_boolean_t *rea
     {
       /* Check if we ended in the middle of a \r\n for one file, but \r for 
          another. If so, back up one byte, so the next loop will back up
-         the entire line. Also decrement *prefix_lines, since we counted one
+         the entire line. Also decrement lines, since we counted one
          too many for the \r. */
       svn_boolean_t ended_at_nonmatching_newline = FALSE;
       for (i = 0; i < file_len; i++)
@@ -437,7 +437,7 @@ find_identical_prefix(svn_boolean_t *rea
                                        || *file[i].curp == '\n';
       if (ended_at_nonmatching_newline)
         {
-          (*prefix_lines)--;
+          lines--;
           DECREMENT_POINTERS(file, file_len, pool);
         }
     }
@@ -453,6 +453,8 @@ find_identical_prefix(svn_boolean_t *rea
   /* Slide one byte forward, to point past the eol sequence */
   INCREMENT_POINTERS(file, file_len, pool);
 
+  *prefix_lines = lines;
+
   return SVN_NO_ERROR;
 }