• labsin@sh.itjust.works
    link
    fedilink
    arrow-up
    2
    ·
    4 months ago

    In later .net version for loops can be slower than linq queries. If the compiler knows the iteration does not cause side effects, it often already does not allocate and can even vectorize some loops, so .Sum(…) might be faster then a manual for loop.

    Optimizing without benchmarking is often wasted effort.

    • xianjam@programming.dev
      link
      fedilink
      English
      arrow-up
      1
      ·
      4 months ago

      Funnily enough, that engineer also disallowed Linq because it was slow. It’s been 7 years since I’ve worked with him. wonder if he ever changed his tune.