On 22/02/11 7:02 AM, David Whetstone wrote:
On Feb 21, 2011, at 8:53 AM, Björn Winckler wrote:
No specific reason that I can remember (or think of). However, I'd rather
avoid changing code unless there is a real problem with it.
Björn
Ah, that's too bad. I understand not wanting to fix what isn't considered
broken, but I'd like to make a small attempt to persuade you reconsider. Here
are three reasons why I think it's a good idea:
1. A large switch statement is more efficient than an
equivalent if-else if ladder (O(1) vs. O(n)).
2. Debugging a large switch statement is much less tedious
than the if-else ladder, which, unless you know which
branch you want ahead of time, requires either a lot of
stepping, or a lot of searching for the right branch to
in which to set a temporary breakpoint.
3. As I previously mentioned, using the enum as a type
rather than an int allows the debugger to display the
mnemonic rather than a cryptic integer value. In
addition, compliers often offer warnings for missing
enum values when an enumeration is used as the
condition for a switch (e.g. gcc's –Wswitch-enum), as
well as warnings for values not in the enumeration.
+1 for the change, from me, though I shouldn't carry much weight.
However, these are good reasons, IMHO, and as long as a couple of people
read the changes rather than blindly committing them, dumb things
shouldn't happen.
Ben.
--
You received this message from the "vim_mac" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php