• CrypticCoffee@lemmy.ml
    link
    fedilink
    arrow-up
    4
    ·
    edit-2
    1 day ago

    Most times overhead is less important than readability and maintainability of code. If someone cannot read your code, they’ll mess it up far worse.

    Optimisation is for bottlenecks. No point making code run in 0.01ms rather than 0.02 if it later hits at 0.7s bottleneck like file io or DB. For most things, readability is everything unless you’re developing operating systems or close to metal libraries. Many compilers will inline functions anyway so the only gain is increased suffering of colleagues and later bugs in production when it’s modified by someone else. Cognitive load is very important and why many static code analysis tools pick it up.

    • Buddahriffic@lemmy.world
      link
      fedilink
      arrow-up
      2
      ·
      18 hours ago

      One has a function that takes the next node as an argument, another just sets that up in a loop. Personally, I found the loop one a bit easier to visualize and debug via stepping through code, though admittedly the difference isn’t huge.