Re: size_t and int comparison
From: Mike Wahler (mkwahler_at_mkwahler.net)
Date: 01/09/05
- Next message: Jerry Coffin: "Re: size_t and int comparison"
- Previous message: Siemel Naran: "Re: How to write such a function?"
- In reply to: Victor Bazarov: "Re: size_t and int comparison"
- Next in thread: Victor Bazarov: "Re: size_t and int comparison"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 09 Jan 2005 21:20:16 GMT
"Victor Bazarov" <v.Abazarov@comAcast.net> wrote in message
news:F9OdnfhbNOT6A3zcRVn-pA@comcast.com...
> "Mike Wahler" <mkwahler@mkwahler.net> wrote...
> > [..]
> > (if the code in your loop does not modify the string, you
> > might get a slight performance improvement by storing the
> > size before the loop and using that:
> >
> > std::vector::size_type sz(pathcmd.size());
> > for(std::vector::size_type i = 0; i < sz; ++i)
> > /* etc */
>
> I personally prefer not to pollute scopes with unnecessary names,
So I'm a litterbug. :-)
> so I'd write
>
> for (std::string::size_type sz = pathcmd.size(), i = 0; i < sz; i++) {
Yes, that's probably better.
> ...
>
> But it often doesn't matter, probably.
Agreed.
-Mike
- Next message: Jerry Coffin: "Re: size_t and int comparison"
- Previous message: Siemel Naran: "Re: How to write such a function?"
- In reply to: Victor Bazarov: "Re: size_t and int comparison"
- Next in thread: Victor Bazarov: "Re: size_t and int comparison"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]