[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
- Re: What tests are run by patchy?, (continued)
- Re: What tests are run by patchy?, David Kastrup, 2013/08/23
- Re: What tests are run by patchy?, Frédéric Bron, 2013/08/23
- Re: What tests are run by patchy?, David Kastrup, 2013/08/23
- Re: What tests are run by patchy?, Frédéric Bron, 2013/08/23
- Re: What tests are run by patchy?, David Kastrup, 2013/08/23
- Premature Optimization, Dan Eble, 2013/08/24
- Re: Premature Optimization,
Frédéric Bron <=