Skip to content

Commit

Permalink
Revert "optimize Filename.checkPathForIllegalChars (#1662)"
Browse files Browse the repository at this point in the history
This reverts commit 9753f72.
  • Loading branch information
KevinRansom committed Oct 27, 2016
1 parent f142979 commit 67c23cb
Showing 1 changed file with 10 additions and 22 deletions.
32 changes: 10 additions & 22 deletions src/utils/filename.fs
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,17 @@ let illegalPathChars =
let chars = Path.GetInvalidPathChars ()
chars

type PathState =
| Legal
| Illegal of path: string * illegalChar: char

let checkPathForIllegalChars =
let cache = System.Collections.Concurrent.ConcurrentDictionary<string, PathState>()
fun (path: string) ->
match cache.TryGetValue path with
| true, Legal -> ()
| true, Illegal (path, c) -> raise(IllegalFileNameChar(path, c))
| _ ->
let len = path.Length
for i = 0 to len - 1 do
let c = path.[i]
let checkPathForIllegalChars (path:string) =
let len = path.Length
for i = 0 to len - 1 do
let c = path.[i]

// Determine if this character is disallowed within a path by
// attempting to find it in the array of illegal path characters.
for badChar in illegalPathChars do
if c = badChar then
cache.[path] <- Illegal(path, c)
raise(IllegalFileNameChar(path, c))
cache.[path] <- Legal

// Determine if this character is disallowed within a path by
// attempting to find it in the array of illegal path characters.
for badChar in illegalPathChars do
if c = badChar then
raise(IllegalFileNameChar(path, c))

// Case sensitive (original behaviour preserved).
let checkSuffix (x:string) (y:string) = x.EndsWith(y,System.StringComparison.Ordinal)

Expand Down

0 comments on commit 67c23cb

Please sign in to comment.