|
Boost : |
Subject: Re: [boost] Boost.Algorithm design question
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-10-06 12:31:45
Christian Holmquist wrote:
> On 5 October 2011 17:53, Stephan T. Lavavej
> <stl_at_[hidden]>wrote:
>
> > #1 is better. It follows the STL's conventions (e.g. look at
> > std::find()) and permits heterogeneous comparisons.
> >
> > Consider vector<string> and val being "meow". string is
> > directly comparable to const char *, without any conversions
> > or temporaries.
>
> The never ending reference to std::string vs const char*
> performance thing. I'm simply amazed about the simplicity of
> other developers performance issues, if this was the main
> bottleneck I would ever deal with I could have more time
> drinking coffee =)
Too much coffee is bad for you, so this is a good thing!
> -IF- such a case would show up in a profiler, I think it's
> only fair to let the developer optimize his scenario with
> some custom code, that to open up this can of worms for
> everyone else.
In the "meow" example above, forcing the construction of a std::string from the string literal implies a free store allocation which, in turn, generally implies a global lock. That means it can be a drag on MT performance. A library function shouldn't impose that if preventing or avoiding it is practicable.
_____
Rob Stewart robert.stewart_at_[hidden]
Software Engineer using std::disclaimer;
Dev Tools & Components
Susquehanna International Group, LLP http://www.sig.com
________________________________
IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk