findutils-patches
[Top][All Lists]
Advanced

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

Re: [Findutils-patches] Patches to -type x,y,z


From: Bernhard Voelker
Subject: Re: [Findutils-patches] Patches to -type x,y,z
Date: Wed, 6 Apr 2016 19:33:22 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0

On 04/06/2016 06:14 PM, Dale R. Worley wrote:
> Bernhard Voelker <address@hidden> writes:
>> I thought a bit about the implementation and thought it'd be better
>> to avoid artificially creating the OR-ed predicates, and rather store
>> the wanted file types in an array and check for that in pred.c.
>> I think this should be faster, too.
> 
> I may be overlooking something, but:
> 
> +  float type_rate = 0.0;
> 
> Is this variable used anywhere?
> 
> +      our_pred->est_success_rate += rate;
> 
> Is est_success_rate set to zero before the loop that contains this?
> Looking at tree.c (albeit from an older version), get_new_pred()
> initializes est_success_rate to 1.0, not 0.0.

Good catch - I wonder why GCC didn't flag this "set but not used" one.
Argh, "-Wall -Werror" should be used when we're in a git checkout.

I'll squash in the following diff:


diff --git a/find/parser.c b/find/parser.c
index 6ea6e05..dfe0523 100644
--- a/find/parser.c
+++ b/find/parser.c
@@ -2679,7 +2679,6 @@ insert_type (char **argv, int *arg_ptr,
             PRED_FUNC which_pred)
 {
   struct predicate *our_pred;
-  float type_rate = 0.0;
   const char *typeletter;
   const char *pred_string = which_pred == pred_xtype ? "-xtype" : "-type";

@@ -2696,6 +2695,7 @@ insert_type (char **argv, int *arg_ptr,
     }

   our_pred = insert_primary_withpred (entry, which_pred, typeletter);
+  our_pred->est_success_rate = 0.0;

   /* Figure out if we will need to stat the file, because if we don't
    * need to follow symlinks, we can avoid a stat call by using


Thanks & have a nice day,
Berny



reply via email to

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