After the first time the if is true, it's quite useless to check the other nOffset of vSorted.
Added some breaks to some BOOST_FOREACH #1735
pull xanatos wants to merge 1 commits into bitcoin:master from xanatos:master changing 3 files +15 −0-
xanatos commented at 1:03 PM on August 28, 2012: none
-
freewil commented at 1:13 PM on August 28, 2012: contributor
LGTM but you should rebase so there isnt 5 commits
-
gmaxwell commented at 5:59 PM on August 28, 2012: contributor
Indeed, this doesn't need three commits and two merges.
Does this actually result in different code? The loops have no real side effects, I don't know how terribly the boost foreach is, but it's not inconceivable to me that the compiler could already do this with these loops because they're simple single assignment.
-
BitcoinPullTester commented at 4:38 PM on August 29, 2012: none
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/bbcb74effad812ebf418627133341ba05e373b95 for binaries and test log.
-
laanwj commented at 5:48 PM on August 29, 2012: member
Would be ok with me if rebased into one commit
-
gavinandresen commented at 5:59 PM on August 29, 2012: contributor
I don't like these kind of obsessive-compulsive source code changes, I think they're a waste of time.
If you're rewriting old code for some reason, then feel free to clean it up. Otherwise I think it is better left alone.
-
jgarzik commented at 6:05 PM on August 29, 2012: contributor
Agree that it does smell like premature optimization, with zero proof of actual need or benefit
-
xanatos commented at 6:42 PM on August 29, 2012: none
The objective isn't only a (probably null) optimization. I see it as "let's make it clear what is the meaning of the code". Is it "looking for at least one element with a condition" or is it "using an hidden side-effect of enumerating the collection/checking the condition"? The first time I watched the code I asked myself: why isn't it breaking if it is only looking for a single value?
For the rebase... I'm a noob of git... This evening I'll try to do it.
-
Added some break(s) to some BOOST_FOREACH de6a850c84
-
xanatos commented at 7:41 PM on August 29, 2012: none
Rebased (I hope... In the end after fighting with the rebase -interactive I installed the TortoiseHg and, after fighting against its rebase I used the reset command)
-
jgarzik commented at 3:58 PM on September 4, 2012: contributor
It's still adding source code and binary code size without much benefit. We definitely appreciate people reading the source codebase this closely, though! It is this kind of attention to detail that benefits all bitcoin users.
- jgarzik closed this on Sep 4, 2012
- owlhooter referenced this in commit 7e96af4e65 on Oct 10, 2018
- DrahtBot locked this on Sep 8, 2021