On 06/07/07, Warren Young <mysqlpp@stripped> wrote:
> Jonathan Wakely wrote:
> > On 02/07/07, Andrew Sayers <andrew-mysqlpp@stripped> wrote:
> >>
> >> +inline std::ostream& operator <<(quote_type1 o,
> >> + char in[])
> >> +{
> >> + return operator <<(o, static_cast<const char*
> const&>(in));
> >> +}
> >
> > Personally I would use simply static_cast<cont char*>(in) if doing that.
>
> Go try it. Andrew and I both know what will happen, but it seems you
> need a demonstration. >:) When you're done, you will understand the
> lament in my previous message in this thread.
ah ok :-)
> > The assembly code shows five instructions
>
> You're trying to save three assembly instructions in a process that
> moves data from a hard disk to a remote program over an IPC channel in
> an intermediate representation, up through two layers of libraries, to a
> program that will reformat that data via the C++ IOStreams library?
> Have you any idea how many clock cycles elapsed in all that? 3 clock
> cycles is so small by comparison that you should express the ratio on a
> logarithmic scale, rather than as a percentage.
>
> If three instructions matters to you, you should be using flat files of
> fixed-length C structs instead of a relational database. That's the
> only way you'll have any hope of being able to measure a meaningful
> performance difference.
No, it doesn't matter at all, of course. I thought the reference was
being used to avoid a copy in the aim of needless efficiency, so was
hoping to counter that with a simpler cast. But I was clearly wrong
about why the reference was there, I should have applied the patch and
tested first. "Do the simplest thing can possibly work" does mean it
has to work! Sorry for the noise.
Jon