On Fri, Jun 17, 2016 at 4:25 PM, Remko Popma <remko.po...@gmail.com> wrote:
> Yes, your suggestion is better. > Not only cleaner, but also more performant: in the first case the cpu will > speculatively execute both branches. One of them will fail and that > execution pipeline will be discarded. Not a big deal, happens all the time, > and branch prediction is very good these days, but if the conditional can > be avoided, the cpu can continue to make progress. If you can choose, > prefer math to branching code. > Done. In Git master. Gary > > Sent from my iPhone > > On 2016/06/18, at 4:50, Gary Gregory <garydgreg...@gmail.com> wrote: > > Should this: > > private int getMinCount(final Strategy strategy) { > if (Strategy.DROP == strategy) { > return 0; > } else { // Strategy.RETAIN > return 1; > } > } > > be: > > private int getMinCount(final Strategy strategy) { > return strategy.getMinCount(); > } > > ? > > Seems more OO to me. > > Gary > > -- > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > Java Persistence with Hibernate, Second Edition > <http://www.manning.com/bauer3/> > JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> > Spring Batch in Action <http://www.manning.com/templier/> > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory > > -- E-Mail: garydgreg...@gmail.com | ggreg...@apache.org Java Persistence with Hibernate, Second Edition <http://www.manning.com/bauer3/> JUnit in Action, Second Edition <http://www.manning.com/tahchiev/> Spring Batch in Action <http://www.manning.com/templier/> Blog: http://garygregory.wordpress.com Home: http://garygregory.com/ Tweet! http://twitter.com/GaryGregory