- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
A shorter version in Java.
Admin
freaky! swear I only hit that submit button once!
Admin
No it wouldn't. The point the original poster made was that the string comparison is insignificant compared to all the operations that a web server must perform to handle a SINGLE request. No matter how many concurrent requests you add, the total number of CPU cycles spent on the string comparison will STILL be insignificant compared to the total number of CPU cycles being spent to service all the requests. Sure, you can make your code more complex and less readable to get a 0.0001% increase in efficiency, but that isn't going to get you much even if the server is overloaded.
CAPTCHA: onomatopoeia, are you kidding?
Admin
Has to be J# - the string array initialisation at the start is a giveaway.
Admin
The problem is that this C# function will always return empty string for URL's in the form specified in the comments. Given a URL '/lang/foo/bar.aspx' the 1'th, 2'nd, and 3'rd indexed characters in the string will always be 'l', 'a', and 'n' respectively. These will never match any of the values in the VALID_FOLDERS array and therefore the function will always return empty string, unless the parameter value is less than four characters in which case it will throw an IndexOutOfRangeException.
Brent
Admin
This is off course the url given in the comment. Quite probably the URL will start with the server, giving the letters: 'ww.'
Also, i18n is often not really a solution when it comes to preferred language. Example: I'm Dutch, my computer is installed in English, and I'm looking up information regarding SuSE (for example) while staying at a friend in southern Belgium (French language area).
The language page I'll want to check is in German, because SuSE simply has more info in German. Other websites I might like to read in English, Dutch, French or ocasionally.
Admin
I think the function qualifies only in that it results in undefined behaviour (or error?) for strings shorter than three chars. In other aspects it looks like a legitimate attempt to do some input checking, by an inexperienced programmer who's nonetheless thinking exactly the right things (test your data before you use it so you can give a meaningful error message, and optimize where it matters). This function doesn't exactly radiate outright stupidity to me, just lack of experience/perspective. Not really fair game.
Google's messy approaches are much more of a WTF if you ask me.
Admin
Admin
Not cool indeed, unless we point out that Americans learn less and declare wars on innocent people more, right? But we don't want to turn this into a pi**ing contest, do we?
What's wrong? You mean beside the fact that UK is a part of Europe (even though some might think they "know better")?
Anyway, if you tend make fun of some country/continent, first learn how to make fun of YOUR country, it's not that hard.
Admin
PLEASE, TELL ME THERE'S SOMEONE OUT THERE STILL READING THIS
THE CODE GOES:
IF (S == "ENG") RETURN "ENG"; IF (S == "DEU") RETURN "DEU";
ETC.
FOR GOD'S SAKE THE SAME CODE CAN BE WRITTEN BY SAYING RETURN S;
THAT IS THE WTF HERE. breathe
(ok, so you need to take into account it not being one of the above and return an empty string instead. big deal. one line of code.)
please tell me this is all some kind of big joke and everybody else did NOT miss this
Admin
What language? My guess is either MUMPS or VB++...
Admin
All the micro-optimizers so far are missing the obvious: using a sorted list and doing a binary instead of linear search would make a much bigger difference than calling substring vs nested if calls, etc. Not that it matters much, since as others said it's like pissing in a river.