Skip to content

Commit 3436247

Browse files
Avoid clone operation in read_multi_values_internal. (#4820)
## Motivation The function `read_multi_values_internal` has to deal with the fact that keys can repeat. So a HashMap is built for storing the key indices. Unfortunately, this leads to a clone operation, while we could have avoided the clone operation for the last one. This is especially bad since in most cases, we would have just one entry. ## Proposal Use the `split_last()` in the access to the indices. ## Test Plan The CI. ## Release Plan That can be backported to TestNet Conway. And this can be a good idea since read operations are problematic on TestNet Conway. ## Links None.
1 parent 0ec9a84 commit 3436247

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

linera-views/src/backends/scylla_db.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,11 @@ impl ScyllaDbClient {
358358

359359
while let Some(row) = rows.next().await {
360360
let (key, value) = row?;
361-
for i_key in &map[&key] {
362-
values[*i_key] = Some(value.clone());
361+
if let Some((&last, rest)) = map[&key].split_last() {
362+
for position in rest {
363+
values[*position] = Some(value.clone());
364+
}
365+
values[last] = Some(value);
363366
}
364367
}
365368
Ok(values)

0 commit comments

Comments
 (0)