Skip to content

Commit 0f59444

Browse files
committed
mwindow: use multiplication instesad of conditionals
This is a very verbose way of performing a comparison where we already have the identity value with both signs. Instead of chainging several conditions, we can rely on the maths working out.
1 parent 55c8433 commit 0f59444

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

src/libgit2/mwindow.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ static bool git_mwindow_scan_recently_used(
240240
* store it in the output parameter. If lru_window is NULL,
241241
* it's the first loop, so store it as well.
242242
*/
243-
if (!lru_window ||
244-
(comparison_sign == GIT_MWINDOW__LRU && lru_window->last_used > w->last_used) ||
245-
(comparison_sign == GIT_MWINDOW__MRU && lru_window->last_used < w->last_used)) {
243+
if (!lru_window || (comparison_sign * w->last_used) > lru_window->last_used) {
246244
lru_window = w;
247245
lru_last = w_last;
248246
found = true;

0 commit comments

Comments
 (0)