Whoa: just found a crashing bug in Retcon, that I wrote *four years* ago. It’s easy to trigger, too: just ⌘↓ a commit that’s right above the very first commit in the history.

(it’s an array indexing bug: the commit has no parent now, so the lookup fails. these days I use `safeIndex:` everywhere.)

If you’re wondering what four years looks like in Retcon’s repo, just look at that scrollbar thumb! The app was still named Bluebird, and deleting commits had been added the day just before. Simpler times.
The code understands nil parents, so the fix is trivial. Four years in the making!

@Cykelero this fix is making it even harder to find your real bug (which still exists) and may lead to data loss due to operating on the wrong item. You likely should track them by ID rather than index.

Edit: I originally read “commit” as a verb here, but whatever you do next has the same problem of having the wrong value.

@Cykelero seeing this finally made me make my copy and paste 'safe' extension into a package 😅

Mostly so whenever I join a new company and see they use '.contains' for theirs, I can point them to these benchmarks https://github.com/brzzdev/swift-safe-subscript#benchmarks

GitHub - brzzdev/swift-safe-subscript: Safe, O(1) [safe:] subscript access for any Swift collection.

Safe, O(1) [safe:] subscript access for any Swift collection. - brzzdev/swift-safe-subscript

GitHub
@brzz Neat! I do wonder what the performance difference is within an actual codebase. It’s probably only visible is more extreme cases, with very frequent subscripting, but there’s no reason to skip on that faster way to check, anyway.