lilypond-devel
[Top][All Lists]
Advanced

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

Re: What tests are run by patchy?


From: David Kastrup
Subject: Re: What tests are run by patchy?
Date: Fri, 23 Aug 2013 15:04:23 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)

Frédéric Bron <address@hidden> writes:

>> Have you double-checked the code g++ generates?  I should not be overly
>> surprised if current versions don't actually do much copying unless
>> required.
>
> I know what you mean: "premature optimization is the root of all
> evil". But here, it is just following standard practice as recommended
> by all textbooks.

Which textbooks would that be?

> The standard <string> library can implement copy on write but it is
> not mandatory and we should not rely on that behaviour.

In C++11, rvalue string copies with move semantics are O(1).

> Also the compiler may do some optimizations and remove some copies
> him-self but should we rely on a particular compiler to do our job
> when it is so "easy" to write efficient code?

You should have rather written "efficient" in quote marks as long as
there is no evidence that the current code is less efficient under some
known compilers.

> When I have finished, I plan to do a time comparison on some scores I
> have. The locations where strings are copied are really numerous and I
> am not planning to remove all of them: I am not checking if we really
> need 'string' as return type instead of 'const string&'. This could be
> another patch...

const string & as return type is madness.  For one thing, it's
guaranteed _not_ to be an efficiency gain in C++11.  For another, it
produces _serious_ destructor/lifetime issues.

-- 
David Kastrup



reply via email to

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