For context, I am trying to do a save system for a game.

  • GetOffMyLan@programming.dev
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    16 days ago

    It is an expensive operation as it needs to unwind the stack to get the stack trace.

    But if you’re checking a single file you won’t notice it.

    If you’re doing it in a tight loop it’ll be very noticeable.

    Checking the file exists also has a cost.

    I likely wouldn’t bother if I was saving a single file especially as there are other exceptions that could be thrown in the process.