You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use built-in URL modifying methods instead of string concat when creating paths.
The `FileIterator` class was using string concat to combine strings into file paths. This isn't very resilient to different types of valid input. The built-in file URL modifying methods (e.g. appendingPathComponent...) are more resilient.
This manifested as an error when trying to format a directory, where I included a trailing `/` in the directory path passed to swift-format. That `/` resulted in `FileIterator` working on paths that included 2 `/` characters. Later on, `deleteLastPathComponent` handles the paths with 2 `/` characters by appending `../`. Eventually, this leads to an infinite loop of appending `../` to the search path when searching for configuration files.
I compared the performance of this implementation with the previous implementation. There wasn't a notable difference. I tested by recursively formatting the swift-protobuf repo:
- Original: 56.7 seconds
- Revised: 56.1 seconds
0 commit comments