migueldeicaza / SwiftTermApp

MIT License
305 stars 29 forks source link

Code cleanup #200

Closed migueldeicaza closed 2 years ago

migueldeicaza commented 2 years ago

Improve the getCurrentKeyWindow:

.map { $0 as? UIWindowScene }
.compactMap { $0 }
Just use .compactMap { $0 as? UIWindowScene } :slightly_smiling_face:
Instead of filter/first, you can do:
.windows.first(where: \.isKeyWindow)
For walking chains, sequences if often useful, like:
for responder in sequence(first: hint, next: \.next) { ... }