Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


On 10/27/2011 07:53 PM, Kevin Hunter wrote:
At 2:49am -0400 Thu, 27 Oct 2011, Stephan Bergmann wrote:
Not an sc expert, but from looking at the code it looks to me like the
default case shall never be reached, but is there to (a) silence
compiler warnings and (b) fire an OSL_FAIL in case there is a
programming error that causes the case to be reached nonetheless (I
usually put a "this cannot happen" into such OSL_FAILs, in good old
Knuth tradition). And since the function still needs to syntactically
return something, even in this "unreachable" case, it returns the
canonic null value.

Huh. Then why use a switch? Why not use an if-else set of clauses? I
recognize that this function may be called a lot, but does an if vs
switch statement mean /that/ much in terms of performance?

But (a) a switch looks that much more cleaner than an if-else-cascade, and (b) you have the same situation with the if-else-cascade anyway, the default switch case corresponding to a final else branch there.

Stephan

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.