Skip to content

Commit

Permalink
refactor: improve speed of mock
Browse files Browse the repository at this point in the history
  • Loading branch information
0xWOF committed Dec 1, 2023
1 parent b57d4b4 commit 25edc55
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Source/TestMock/MockFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,10 @@ extension MockFunction {

extension MockFunction {
public func callAsFunction(_ argument: Argument) -> Result {
defer { lock.unlock() }
lock.lock()

let result = implementation(argument)
lock.lock()
calls.append(MockFunctionCall(argument: argument, result: result))
lock.unlock()
self.callback(argument, result)

return result
Expand Down

0 comments on commit 25edc55

Please sign in to comment.