// if self is known to be empty, which way is better to
// return a empty array?
extension Array {
func fooAAA() -> Self {
self
}
func fooBBB() -> Self {
[]
}
}
they are exactly the same, and the compiler even knows that they are identical and can substitute them, see:
the compiler created the different versions in your example because you did not compile with -whole-module-optimization enabled, so the compiler did not know that there was no code in a different file that might have to call fooAAA on a non-empty Array.