Skip to content

Instantly share code, notes, and snippets.

@kasrababaei
Created January 31, 2025 04:56
Show Gist options
  • Save kasrababaei/87e21a7df0b09f1dc843f60007ca9757 to your computer and use it in GitHub Desktop.
Save kasrababaei/87e21a7df0b09f1dc843f60007ca9757 to your computer and use it in GitHub Desktop.
Command Mean [s] Min [s] Max [s]
!isEmpty 3.304 ± 0.049 3.221 3.422
isEmpty == false 4.082 ± 0.511 3.235 4.551
isEmpty.isFalse 3.294 s ± 0.050 3.192 3.420

The data is collected by using hyperfine to run each case 100 times:

hyperfine --prepare 'rm -rf ./.build' --runs 100 'swift build'
@kasrababaei
Copy link
Author

Here's the implementation for isFalse:

public extension Bool {
  var isFalse: Bool {
      !self
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment