• bvs23bkv33 (unregistered)

    new Comment.append(

  • Karsten Bock (github) in reply to bvs23bkv33
    new Comment.append(
    
  • Little Bobby Tables (unregistered)

    Almost looks autogenerated.

  • zybex (unregistered)
    new Comment.append(
        new Comment.append(
            new Comment.append(
                new Comment.append(
                    new Comment.append(
                        new Comment.append("Hey, if it compiles...").ToString()
                    .ToString()
                .ToString()
            .ToString()
        .ToString()
    .ToString();
    
  • doubting_poster (unregistered) in reply to Little Bobby Tables

    Looks like it used to be a simple string concatenation, but the coder was told to use StringBuilder(/Buffer) instead. So he did.

  • Jinks (unregistered)

    Loos like a search/replace of "String" with "StringBuffer".

    But yeah, if I saw that in some code I'd definitely say WTF?

  • Lothar (unregistered)

    Maybe copy&pasted from a decompilation. I've seen these constructs show up when decompiling Java classes. And it already happened that a source got lost so it was "reconstructed" by decompiling the class-file.

  • (nodebb)

    At least it's thread-safe.

  • (nodebb)

    Especially noteworthy is the actual chaining of 2 consecutive .append() calls to the same instance in the middle. Sort of breaks the flow, so to speak.

  • I dunno LOL ¯\(°_o)/¯ (unregistered)

    .append("Robert'); DROP TABLE students;--").ToString()

  • AI (unregistered)

    The real WTF is a language where they provide fast string concatenation -- but instead do it the stupid way by default

  • (nodebb)

    Sheesh. This isn't even dotnet. This is the ancient and honorable thread-safe Java StringBuffer class. Maybe this is a hardware diagnostic for interlocked thread-safe instructions.

Leave a comment on “Classic WTF: The not-so-efficient StringBuilder”

Log In or post as a guest

Replying to comment #506514:

« Return to Article