Skip to content

Commit

Permalink
Remove extra min call
Browse files Browse the repository at this point in the history
No need to protect against large values of 2 ** $attempt.
  • Loading branch information
trowski committed Dec 8, 2024
1 parent 4230413 commit decbcc8
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/FileMutex.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ public function acquire(?Cancellation $cancellation = null): Lock
}

// Windows fails to open the file if a lock is held.
$multiplier = 2 ** \min(7, $attempt);
delay(\min(self::DELAY_LIMIT, self::LATENCY_TIMEOUT * $multiplier), cancellation: $cancellation);
delay(\min(self::DELAY_LIMIT, self::LATENCY_TIMEOUT * (2 ** $attempt)), cancellation: $cancellation);
}
}
} catch (FilesystemException|StreamException $exception) {
Expand Down
3 changes: 1 addition & 2 deletions src/Internal/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ function lock(string $path, $handle, LockMode $mode, ?Cancellation $cancellation
);
}

$multiplier = 2 ** \min(7, $attempt);
delay(\min($delayLimit, $latencyTimeout * $multiplier), cancellation: $cancellation);
delay(\min($delayLimit, $latencyTimeout * (2 ** $attempt)), cancellation: $cancellation);
}
}

Expand Down

0 comments on commit decbcc8

Please sign in to comment.