Skip to content

Commit 80ee5c1

Browse files
committed
Simplify logic of compare_packages
Signed-off-by: Julien Jerphanion <git@jjerphan.xyz>
1 parent 33cb6d8 commit 80ee5c1

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

libmamba/src/core/shards.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,18 +1098,17 @@ namespace mamba
10981098
return version_b.value() < version_a.value(); // Descending order
10991099
}
11001100
}
1101-
else if (version_a.has_value() || version_b.has_value())
1101+
1102+
// If only one can be parsed, prefer the parsed one
1103+
if (version_a.has_value() || version_b.has_value())
11021104
{
1103-
// If only one can be parsed, prefer the parsed one
11041105
return !version_a.has_value();
11051106
}
1106-
else
1107+
1108+
// Fallback to string comparison if parsing fails
1109+
if (record_a.version != record_b.version)
11071110
{
1108-
// Fallback to string comparison if parsing fails
1109-
if (record_a.version != record_b.version)
1110-
{
1111-
return record_b.version < record_a.version; // Descending order
1112-
}
1111+
return record_b.version < record_a.version; // Descending order
11131112
}
11141113

11151114
// Finally compare by build number (descending - highest first)

0 commit comments

Comments
 (0)