Skip to content

Commit

Permalink
perform Cache factory while locked
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsim committed Jan 2, 2017
1 parent 53d0cf6 commit 8906da6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Source/SwiftLintFramework/Extensions/File+Cache.swift
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,12 @@ private struct Cache<T> {
fileprivate mutating func get(_ file: File) -> T {
let key = file.cacheKey
lock.lock()
defer { lock.unlock() }
if let cachedValue = values[key] {
lock.unlock()
return cachedValue
}
lock.unlock()
let value = factory(file)
set(key: key, value: value)
values[key] = value
return value
}

Expand Down

0 comments on commit 8906da6

Please sign in to comment.