kylef / PathKit

Effortless path operations in Swift
BSD 2-Clause "Simplified" License
1.45k stars 169 forks source link

Why use NSString? #70

Open kateinoigakukun opened 4 years ago

kateinoigakukun commented 4 years ago

Thanks for useful library 😄

While investigating performance problem, I found this library converts Swift.String into NSString and it's very high cost operation.

Why this library uses NSString instead of implementing its own logic?

xhruso00 commented 4 years ago

If you look into code you see "expandingTildeInPath" which is defined in @interface NSString (NSStringPathExtensions). Code behind expandingTildeInPath is NSFileManager + NSHomeDirectory which use NSString. What is your solution/workaround?

kateinoigakukun commented 4 years ago

I mean using these Obj-C API is convenient but high cost, so I prefer to implement the logics in pure Swift in aspect of performance.

It would be very valuable improvement because this library is used in many popular OSS 👍 If I can get agreements from this project author, I'll implement it.

michaeleisel commented 4 years ago

see https://github.com/kylef/PathKit/pull/72/files#r391294029 for some mitigation