Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-20 Thread Stephan Bergmann
On 02/18/2012 03:21 PM, julien2412 wrote: This subject, switch/if else, reminded me what I read recently on the Stroustrup book. 1) The fact that switch allows a better quality machine code. I wouldn't bet anything on that one. Compilers should be able to automatically identify

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-18 Thread Mariusz Dykierek
I have a 'replacement' patch that actually replaces most of if...else if...else chains with switches. They are more legible and seem natural when choosing branches depending on the same variable. The performance of a switch should also be better, but turbo boost should not be expected ;). Two

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-18 Thread Ivan Timofeev
On 18.02.2012 17:29, Mariusz Dykierek wrote: I have a 'replacement' patch that actually replaces most of if...else if...else chains with switches. Great! They are more legible and seem natural when choosing branches depending on the same variable. On the other hand, the evaluated

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-18 Thread Mariusz Dykierek
On 2012-02-18 14:41, Ivan Timofeev wrote: On 18.02.2012 17:29, Mariusz Dykierek wrote: I have a 'replacement' patch that actually replaces most of if...else if...else chains with switches. Great! They are more legible and seem natural when choosing branches depending on the same

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-18 Thread julien2412
This subject, switch/if else, reminded me what I read recently on the Stroustrup book. 1) The fact that switch allows a better quality machine code. 2) an enumeration used with a switch allows a compiler to detect a case which has be forgotten. Now, I'm not a senior C++ dev at all, just a

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] - [core/vcl/source/window/splitwin.cxx:2045]: (style) Found duplicate branches for if and else.

2012-02-16 Thread Riccardo Magliocchetti
Il 16/02/2012 00:02, Mariusz Dykierek ha scritto: + some simplification +sal_Bool bLeft = sal_True; +if ( ( meAlign == WINDOWALIGN_TOP ) || ( meAlign == WINDOWALIGN_LEFT ) ) +bLeft = sal_False; I think that keeping possible values explicit could be a good thing

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] - [core/vcl/source/window/splitwin.cxx:2045]: (style) Found duplicate branches for if and else.

2012-02-16 Thread Stephan Bergmann
On 02/16/2012 09:35 AM, Riccardo Magliocchetti wrote: Otherwise you can simplify it even more: sal_Bool bLeft = (meAlign == WINDOWALIGN_TOP || meAlign == WINDOWALIGN_LEFT) ? sal_False : sal_True; ... which of course reduces to bool bLeft = !(meAlign == WINDOWALIGN_TOP || meAlign ==

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] - [core/vcl/source/window/splitwin.cxx:2045]: (style) Found duplicate branches for if and else.

2012-02-16 Thread Mariusz Dykierek
On 2012-02-16 10:02, Stephan Bergmann wrote: On 02/16/2012 09:35 AM, Riccardo Magliocchetti wrote: Otherwise you can simplify it even more: sal_Bool bLeft = (meAlign == WINDOWALIGN_TOP || meAlign == WINDOWALIGN_LEFT) ? sal_False : sal_True; ... which of course reduces to bool bLeft =

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-16 Thread Matteo Casalin
Hi all, -- Mariusz Dykierek mariuszdykie...@gmail.com wrote: (16/02/2012 11:46) On 2012-02-16 10:02, Stephan Bergmann wrote: On 02/16/2012 09:35 AM, Riccardo Magliocchetti wrote: Otherwise you can simplify it even more: sal_Bool bLeft =

Re: [PATCH] [core/vcl/source/window/splitwin.cxx:2047] -[core/vcl/source/window/splitwin.cxx:2045]:(style) Found duplicate branches for if and else.

2012-02-16 Thread Stephan Bergmann
On 02/16/2012 12:18 PM, Matteo Casalin wrote: I personally find 'if' more legible than ?: and definitely expressions like b = x==y || x==z; I am not sure if WindowAlign will always have only these 4 members and possibly the author of the original version wasn't either (thus final else). Since

[PATCH] [core/vcl/source/window/splitwin.cxx:2047] - [core/vcl/source/window/splitwin.cxx:2045]: (style) Found duplicate branches for if and else.

2012-02-15 Thread Mariusz Dykierek
+ some simplification -- Regards, Mariusz Dykerek diff --git a/vcl/source/window/splitwin.cxx b/vcl/source/window/splitwin.cxx index f5da206..09ad468 100644 --- a/vcl/source/window/splitwin.cxx +++ b/vcl/source/window/splitwin.cxx @@ -2035,17 +2035,9 @@ void SplitWindow::ImplDrawFadeIn(