• bvs23bkv33 (unregistered)

    Comment(first).InnerText.Replace("first", "");

  • gnasher729 (unregistered)

    The wonders of temporary variables. I mean it's 20 seconds to make this readable and much better performing.

  • Abe (unregistered)

    isPolicy || !jePolica sounds slavic, maybe || !nieMaPolicy ;-) is missing

  • Aspie (unregistered)

    Where's the bit that increments the value of index? Doesn't this produce an infinite loop?

    Remy: It's reasonable to assume that index gets incremented in the commented out section- the submitter didn't provide that.

  • Mike Rosoft (unregistered) in reply to Abe

    I think it means "is shelf".

  • Vilx- (unregistered)

    I don't see any regexes here. Just some regular String.Replace(). Still pretty awful though. On the other hand, I don't see that much to improve. Yes, the cloning is a WTF, but the rest... without knowing the requirements there's not much else to optimize. You might shuffle things around for a little bit more readability, but that's pretty much it.

  • Anon (unregistered)

    The beauty of JS; Replace is both string replace as well as regex replace :p https://www.w3schools.com/jsref/jsref_replace.asp

  • Zach (unregistered) in reply to Vilx-

    If there's that much in a while clause then there is something wrong with the code. There should be a way to clean it up

  • (nodebb)

    "je polica" means "is policy." Really.

  • Dave (unregistered)

    This needs a bit more context to say if it's a WTF or sensible use of just-good-enough code. It really depends on whether this is code that will run occasionally or all the time: if it takes half a second longer to compile a report once a month, it's not worth even two minutes to optimise it for performance, let alone paying a proper developer to do it right instead of an intern to do it OK.

  • (nodebb)

    There's always two of me just replacing around.

  • Alex (unregistered)

    What's the fuzz about cost of evaluating the statements, like "the body of the loop is cheaper to evaluate than the loop condition"? So what?

    This seems to be a simple "do { move to next thing } while ( there are more things && it's not the thing we're looking for )". That's an OK pattern, even if the conditional is more complex than the body. Granted, the conditional itself is WTF, but the rest?

  • Code Refactorer (unregistered) in reply to Alex

    This code was programmed in a copy-and-paste style. The developer saved himself 2 or 3 seconds and every reader needs additional 15 seconds, just to decide "there are more things && it's not the thing we're looking for" (Quotation of commenter Alex). That's the real WTF. Because code is written once, but read many times (average 10). Commenter Vilx thinks there is not much to optimize instead of reformatting code. That's wrong. So to clean-up you should write a single method that you call with different parameters instead of copy-pasting code, like: function isPolicy(xpathPolicyNo, policyNumberSystem) { return nodeList.Item(index).CloneNode(true).SelectSingleNode(xpathPolicyNo, XmlNsMngr).InnerText.Replace("\n", "").Replace("\t", "").Replace("\r", "") == policyNumberSystem; }

  • Murray (unregistered)

    I'm still waiting for the flame war around singular "they".

  • mike (unregistered)

    The real WTF is:

    "XmlNodeList nodeList = ..."

    Nothing good ever followed that in my experience.

  • My Name (unregistered) in reply to Murray

    Anneke can actually be both "Annie" and "Arnie". Perhaps the author didn't deem it worthwhile to ask the submitter for clarification.

  • My Name (unregistered) in reply to Scott Hannen

    Of course, it's obviously a calque of "IsPolicy" above. In Serbo-Croatian, maybe in Slovenian.

Leave a comment on “My Condition is Complicated”

Log In or post as a guest

Replying to comment #500378:

« Return to Article