Click here to Skip to main content

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrasing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: Let's "switch" to Something Else PinmemberH.Brydon13-Apr-13 14:22 
GeneralRe: Let's "switch" to Something Else PinmemberPIEBALDconsult13-Apr-13 19:39 
GeneralRe: Let's "switch" to Something Else PinmemberH.Brydon14-Apr-13 9:07 
GeneralRe: Let's "switch" to Something Else PinmvpOriginalGriff3-Apr-13 6:25 
It's ugly, yes.
 
But it also has the potential to be fast. By loading the three characters and one space into a machine word, it is a single machine instruction to compare each value, and if the compiler spots that - and it damn well should - then it can use a machine-word look up table and index into a machine-word jump table. And you can't get much faster than that!
 
If this is in time-critical code, then it could be justified. Provided it was well commented. If it's in user input handling, then the author needs to meet Mr Firing Squad for being too "clever". Laugh | :laugh:
The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

GeneralRe: Let's "switch" to Something Else PinmemberTom Delany3-Apr-13 8:02 
GeneralRe: Let's "switch" to Something Else PinmvpOriginalGriff3-Apr-13 8:14 
GeneralRe: Let's "switch" to Something Else PinmemberBobJanova3-Apr-13 23:27 
GeneralRe: Let's "switch" to Something Else Pinmemberjibalt5-Apr-13 19:20 
GeneralRe: Let's "switch" to Something Else PinmemberBobJanova8-Apr-13 0:48 
GeneralRe: Let's "switch" to Something Else Pinmemberjibalt8-Apr-13 23:42 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.


Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 23 Jul 2014
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid