bug-gnulib
[Top][All Lists]
Advanced

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

Re: [PATCH] diffseq: remove useless assignment to "best"


From: Bruno Haible
Subject: Re: [PATCH] diffseq: remove useless assignment to "best"
Date: Sat, 21 Nov 2009 14:37:33 +0100
User-agent: KMail/1.9.9

Jim Meyering wrote:
> At that point "best" is already guaranteed to be zero.

The variable 'best' is used for two different purposes here: for two different
searches in opposite directions. Therefore it does not increase maintainability
to rely on the result of the first search loop for the initialization of the
second loop, if the two loops are actually independent. I'm therefore
applying this follow-up that reduces the scope of the variables.

Bruno


2009-11-21  Bruno Haible  <address@hidden>

        diffseq: reduce scope of variable 'best'.
        * lib/diffseq.h (diag) [USE_HEURISTIC]: Reduce scope of 'best'
        variable, earlier used for two different purposes.

diff --git -b a/lib/diffseq.h b/lib/diffseq.h
index 509dac8..0c1723f 100644
--- a/lib/diffseq.h
+++ b/lib/diffseq.h
@@ -1,6 +1,6 @@
 /* Analyze differences between two vectors.
 
-   Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2008 Free
+   Copyright (C) 1988-1989, 1992-1995, 2001-2004, 2006-2009 Free
    Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
@@ -262,6 +262,7 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, 
bool find_minimal,
 
       if (200 < c && big_snake && ctxt->heuristic)
        {
+         {
          OFFSET best = 0;
 
          for (d = fmax; d >= fmin; d -= 2)
@@ -298,6 +299,10 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, 
bool find_minimal,
              part->hi_minimal = false;
              return;
            }
+         }
+
+         {
+           OFFSET best = 0;
 
          for (d = bmax; d >= bmin; d -= 2)
            {
@@ -334,6 +339,7 @@ diag (OFFSET xoff, OFFSET xlim, OFFSET yoff, OFFSET ylim, 
bool find_minimal,
              return;
            }
        }
+       }
 #endif /* USE_HEURISTIC */
 
       /* Heuristic: if we've gone well beyond the call of duty, give up




reply via email to

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