mirror of
https://github.com/deuxfleurs-org/garage.git
synced 2026-08-25 20:06:53 +00:00
refactor: use u64::midpoint instead of manual implementation
warning: manual implementation of `midpoint` which can overflow help: for further information visit https://rust-lang.github.io/rust-clippy/rust-1.93.0/index.html#manual_midpoint
This commit is contained in:
@@ -183,5 +183,6 @@ strip = "debuginfo"
|
|||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
# pedantic lints configuration
|
# pedantic lints configuration
|
||||||
doc_markdown = "warn"
|
doc_markdown = "warn"
|
||||||
|
manual_midpoint = "warn"
|
||||||
semicolon_if_nothing_returned = "warn"
|
semicolon_if_nothing_returned = "warn"
|
||||||
unnecessary_semicolon = "warn"
|
unnecessary_semicolon = "warn"
|
||||||
|
|||||||
@@ -527,16 +527,16 @@ impl LayoutVersion {
|
|||||||
let mut s_up = self.get_total_capacity();
|
let mut s_up = self.get_total_capacity();
|
||||||
while s_down + 1 < s_up {
|
while s_down + 1 < s_up {
|
||||||
g = self.generate_flow_graph(
|
g = self.generate_flow_graph(
|
||||||
(s_down + s_up) / 2,
|
u64::midpoint(s_down, s_up),
|
||||||
zone_to_id,
|
zone_to_id,
|
||||||
&empty_set,
|
&empty_set,
|
||||||
zone_redundancy,
|
zone_redundancy,
|
||||||
)?;
|
)?;
|
||||||
g.compute_maximal_flow()?;
|
g.compute_maximal_flow()?;
|
||||||
if g.get_flow_value()? < (NB_PARTITIONS * self.replication_factor) as i64 {
|
if g.get_flow_value()? < (NB_PARTITIONS * self.replication_factor) as i64 {
|
||||||
s_up = (s_down + s_up) / 2;
|
s_up = u64::midpoint(s_down, s_up);
|
||||||
} else {
|
} else {
|
||||||
s_down = (s_down + s_up) / 2;
|
s_down = u64::midpoint(s_down, s_up);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user