lilypond-devel
[Top][All Lists]
Advanced

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

Re: Premature Optimization


From: Frédéric Bron
Subject: Re: Premature Optimization
Date: Sat, 24 Aug 2013 19:18:08 +0200

> Two choices have been mentioned.  One is
>   1) void function(std::string);
>   2) void function(const std::string&);
>
> In my professional experience, we usually pass a structure by reference when 
> it can't fit in a register. We always use (2) with strings that the function 
> will not modify. We also pass smart pointers by const reference when the 
> function will not create new references to the pointee.

The patch is ready. All tests pass.
 83 files changed, 248 insertions(+), 254 deletions(-)

There is no significant time improvement with it. I wait for another
patch to be pushed (if accepted) before commiting to ritveld because
both patches interact. Then a discussion can start but if David says
no, I'd better just not submit the patch. It has still been useful
helping me to go inside lilypond.

> The other choice is
>
>   3) std::string getSomeMember() const;
>   4) const std::string& getSomeMember() const;
>
> Reasonable people might disagree, but IMHO this is premature optimization.  
> It is better to use (3), trust the compiler to do return value optimization, 
> and wait for profiling to prove that there is any problem. I share David's 
> concern that (4) can lead to bugs, and as above, not having to worry about 
> those details frees a contributor to focus on the goal.

I can understand this.

Frédéric



reply via email to

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