• auf@lemmy.ml
    link
    fedilink
    arrow-up
    78
    arrow-down
    1
    ·
    9 months ago

    Thief way is actually the best among all of these imo, in terms of readability and efficiency.

        • Aceticon@lemmy.world
          link
          fedilink
          arrow-up
          3
          ·
          edit-2
          9 months ago

          I was under the impression that modern compilers just inline something like that, and even in older languages (like C) use trickeries are used to inline it (typically MAX is a macro rather than a real function, so its always inlined)

          Ultimatelly it depends not just on what you’re doing but also the language and compiler you’re using.

        • Demonen@lemmy.ml
          link
          fedilink
          English
          arrow-up
          2
          ·
          9 months ago

          If you’re optimizing that hard you should probably sort the data first anyway, but yeah, sometimes it’s absolutely called for. Not that I’ve actually needed that in my professional career, but then again I’ve never worked close enough to metal for it to actually matter.

          That said, all of these are implemented as functions, so they’re already costing the function call anyway…

    • snowe@programming.dev
      link
      fedilink
      arrow-up
      17
      arrow-down
      1
      ·
      9 months ago

      They’re setting a variable to a function. Just use the original function. All thief does is obfuscate for literally no gain except character count.