summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <carlosmn@github.com>2022-04-29 10:50:02 +0200
committerCarlos Martín Nieto <carlosmn@github.com>2022-04-29 10:50:02 +0200
commit0f5944459beb952fd49461dfb3c2867de7df314b (patch)
tree482dfea49a6c11a13a59aa861278a5856cb78ecd
parent55c843336b04d3d2a79f24f145ad5db1f3537792 (diff)
downloadlibgit2-0f5944459beb952fd49461dfb3c2867de7df314b.tar.gz
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.
-rw-r--r--src/libgit2/mwindow.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/src/libgit2/mwindow.c b/src/libgit2/mwindow.c
index 5c5f9a893..ad649490a 100644
--- a/src/libgit2/mwindow.c
+++ b/src/libgit2/mwindow.c
@@ -240,9 +240,7 @@ static bool git_mwindow_scan_recently_used(
* store it in the output parameter. If lru_window is NULL,
* it's the first loop, so store it as well.
*/
- if (!lru_window ||
- (comparison_sign == GIT_MWINDOW__LRU && lru_window->last_used > w->last_used) ||
- (comparison_sign == GIT_MWINDOW__MRU && lru_window->last_used < w->last_used)) {
+ if (!lru_window || (comparison_sign * w->last_used) > lru_window->last_used) {
lru_window = w;
lru_last = w_last;
found = true;