75
rov3rand0m
161d

18000 duplicate lines that were manually copy pasted by the previous programmer.

I replaced them with a for loop.

I don’t think it was that hard…

Comments
  • 1
    Oh shit
  • 1
    I have heard that replacing for loops with repeated commands is sometimes more efficient, but I don't think that was the reason here, especially for 18000 iterations.
  • 13
    "18000 duplicated lines that were manually copy pasted by a monkey"

    Here, I fixed your typo.
  • 7
    @theabbie some compilers already make this optimization for you
  • 6
    @theabbie the technique is "loop unwinding"
  • 3
    @iiii yup, and its been pretty useless for the last 20+ years, atleast in compiled languages as any sane compiler does it for you when it is beneficial. (i.e whenever unwinding won't cause you to flood the l1 cache)
  • 1
    @ItsNotMyFault depends, I guess. Compilers are smart indeed, but still not totally smarter. Depends on a compiler of course
  • 4
    Now now, I think that person is a great candidate for Yandere Simulator development.
  • 2
    @theabbie That depends on the language, and if the loop only goes once or twice or how many times the compiler/interpreter need to see before unwinding the loop.
  • 1
    @theabbie this kind of optimizations isn’t done by the compiler?
  • 2
    It's 2021... the guy obviously identifies as a compiler.
  • 1
    @theabbie I wouldn't do it by hand in most cases though, the compiler can often figure out when it's a good idea to do it
Add Comment