1
1
mirror of https://github.com/qvacua/vimr.git synced 2024-12-26 07:13:24 +03:00

Refactor slightly

This commit is contained in:
Tae Won Ha 2016-10-07 18:06:58 +02:00
parent 25f44ca1de
commit b0ec35bb1d
No known key found for this signature in database
GPG Key ID: E40743465B5B8B44

View File

@ -49,8 +49,8 @@ class FileUtils {
}
let pathComps = urls.map { $0.pathComponents }
let min = pathComps.reduce(pathComps[0].count) { (result, comps) in result < comps.count ? result : comps.count }
let pathCompsOnlyMin = pathComps.map { Array($0[0..<min]) }
let min = pathComps.map { $0.count }.min()!
let pathCompsOnlyMin = pathComps.map { $0[0..<min] }
let commonIdx = (0..<min).reversed().reduce(min - 1) { (result, idx) in
if Set(pathCompsOnlyMin.map { $0[idx] }).count > 1 {
return idx - 1