Swift/RandomAccessCollectionに準拠しているCollectionの場合はcountの時間計算量がO(1)
#Swift
モチベーション
Apollo iOSのコードを読んでいて、.count == 0 なるコードがあったので .isEmpty に書き換えられるじゃん!と思った
https://github.com/apollographql/apollo-ios/blob/e76c9e7508cf18bad1ac13866e4436d8ebdc92ba/Sources/ApolloWebSocket/DefaultImplementation/WebSocket.swift#L574
/icons/hr.icon
RandomAccessCollectionに準拠したCollectionのcountの時間計算量が0なことに気がついて変える必要はなかった…
https://developer.apple.com/documentation/swift/collection/count-4l4qk
DictionaryのcountもO(1)
https://developer.apple.com/documentation/swift/dictionary/count
…逆に何のcountがO(n)なんだっけ?
ArrayやDisctionaryが準拠してるから基本的には考えなくて良さそう、出くわしたら調べる、で良い
全体的にisEmptyが使われているのでPRを出した
https://github.com/apollographql/apollo-ios/pull/3217