dolfin team mailing list archive
-
dolfin team
-
Mailing list archive
-
Message #25492
Re: RFC: remove (container.size() == 0) idiom
-
To:
"Garth N. Wells" <gnw20@xxxxxxxxx>
-
From:
Anders Logg <logg@xxxxxxxxx>
-
Date:
Thu, 1 Mar 2012 09:46:57 +0100
-
Authentication-results:
mr.google.com; spf=pass (google.com: domain of logg@xxxxxxxxx designates 10.112.86.198 as permitted sender) smtp.mail=logg@xxxxxxxxx
-
Cc:
dolfin@xxxxxxxxxxxxxxxxxxx
-
In-reply-to:
<CAA4C66NvZs=wbPMuYaXG5WsrnoXEn9tWL1h344V44qHia31jWw@mail.gmail.com>
-
User-agent:
Mutt/1.5.21 (2010-09-15)
On Thu, Mar 01, 2012 at 08:29:25AM +0000, Garth N. Wells wrote:
> On 1 March 2012 08:22, Marco Morandini <morandini@xxxxxxxxxxxxxx> wrote:
> > There are some occurrences of
> >
> > container.size() == 0
> >
> > scattered throughout the code
> > (and fewer of container.size() != 0) .
> > Many of them are harmless, i.e. whenever container
> > is a vector. Some of them, however,
> > are for maps of sets (e.g. dolfin/adaptivity/Extrapolation.cpp:149 ),
> > leading to completely unnecessary O(N) operations (racall that size() is
> > O(N) for a map or a list).
> >
>
> Thanks for pointing this out.
I didn't know about this.
> > I'd like to prepare a (mostly mechanical) patch that changes them into
> > container.empty() .
> >
> > Would be acceptable to change all of them (I'd like to go for this route) or
> > should I change only the places where container is not a vector?
> >
>
> For consistency, I suggest using empty() everywhere. I'd be happy for
> you to make the changes and push a branch to Launchpad.
Me too.
--
Anders
Follow ups
References