[Top][All Lists]

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

Re: [Nano-devel] [PATCH] browser: inaccessible directory remains unselec

From: Benno Schulenberg
Subject: Re: [Nano-devel] [PATCH] browser: inaccessible directory remains unselected when tabbed in goto directory prompt
Date: Sat, 02 Jul 2016 12:43:33 +0200

On Fri, Jul 1, 2016, at 16:21, Rishabh Dave wrote:
> On Fri, Jul 1, 2016 at 3:45 PM, Benno Schulenberg
> > +           /* Snip a trailing slash, so the name can be compared. */
> > +           if (strlen(newpath) > 1 && newpath[strlen(newpath) - 1] == '/')
> > +               newpath[strlen(newpath) - 1] = '\0';
> >
> > This calls strlen() three times, but we are not in a hurry here.
> > And... maybe the compiler is smart enough to not actually make
> > that call three times in a row.
> Intially I too wrote this way but I wasn't sure, so changed my decision.

When you hesitate, opt for fewer lines.  Optimization is for later,
and only where things happen more than a hundred times in a row.

> At last moment, I saw variable "i" which we are reusing right below.
> So, technically, we can reuse it here too.

Ugly.  It is common to use 'i' as an iterating variable, so it is fine
to reuse it below.  (In fact, its first use is what I don't like.)  But
using it to temporarily store something specific is... disrecommendable.

Thanks for the patch.  Pushed in 4957c11, with some adaptations
in the commit message and the removal of a blank line.


-- - Accessible with your email software
                          or over the web

reply via email to

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