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 2010/11/27 23:57:17 UTC
svn commit: r1039781 -
/subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c
Author: jcorvel
Date: Sat Nov 27 22:57:17 2010
New Revision: 1039781
URL: http://svn.apache.org/viewvc?rev=1039781&view=rev
Log:
On the diff-optimizations-tokens branch:
* subversion/libsvn_diff/token.c
(find_identical_prefix): Remove redundant code by reshuffling while loop,
incorporating reading of the first token.
Modified:
subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c
Modified: subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c
URL: http://svn.apache.org/viewvc/subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c?rev=1039781&r1=1039780&r2=1039781&view=diff
==============================================================================
--- subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c (original)
+++ subversion/branches/diff-optimizations-tokens/subversion/libsvn_diff/token.c Sat Nov 27 22:57:17 2010
@@ -204,32 +204,10 @@ find_identical_prefix(svn_boolean_t *rea
*prefix_lines = 0;
*reached_one_eof = FALSE;
-
- /* Read first token from every datasource, and check if it matches. */
- for (i = 0; i < datasource_len; i++)
- {
- SVN_ERR(vtable->datasource_get_next_token(NULL, &token[i],
- diff_baton, datasource[i]));
- *reached_one_eof = *reached_one_eof || token[i] == NULL;
- }
- if (*reached_one_eof)
+ while (1)
{
- /* We're done. Push back tokens that we may have read too much. */
- for (i = 0; i < datasource_len; i++)
- if (token[i] != NULL)
- SVN_ERR(vtable->token_pushback_prefix(diff_baton, token[i], datasource[i]));
- return SVN_NO_ERROR;
- }
- for (i = 1, is_match = TRUE; is_match && i < datasource_len; i++)
- {
- SVN_ERR(vtable->token_compare(diff_baton, token[0], token[i], &rv));
- is_match = is_match && rv == 0;
- }
-
- /* While tokens match up, continue getting tokens and matching. */
- while (is_match)
- {
- (*prefix_lines)++;
+ /* Keep getting tokens and matching them, until there are no tokens
+ left, or we encounter a non-matching token. */
for (i = 0; i < datasource_len; i++)
{
SVN_ERR(vtable->datasource_get_next_token(NULL, &token[i],
@@ -237,13 +215,21 @@ find_identical_prefix(svn_boolean_t *rea
*reached_one_eof = *reached_one_eof || token[i] == NULL;
}
if (*reached_one_eof)
- break;
+ {
+ break;
+ }
else
- for (i = 1, is_match = TRUE; is_match && i < datasource_len; i++)
- {
- SVN_ERR(vtable->token_compare(diff_baton, token[0], token[i], &rv));
- is_match = is_match && rv == 0;
- }
+ {
+ for (i = 1, is_match = TRUE; is_match && i < datasource_len; i++)
+ {
+ SVN_ERR(vtable->token_compare(diff_baton, token[0], token[i], &rv));
+ is_match = is_match && rv == 0;
+ }
+ if (is_match)
+ (*prefix_lines)++;
+ else
+ break;
+ }
}
/* If all files reached their end (i.e. are fully identical), we're done. */