Take iterator in calculate_hash()

Avoids unnecessary allocations.
This commit is contained in:
Lambda 2024-08-26 19:16:51 +00:00
parent cce83beedb
commit f1642c92d1
5 changed files with 24 additions and 33 deletions

View file

@ -133,9 +133,8 @@ impl Service {
let previous_shortstatehash =
self.db.get_room_shortstatehash(room_id)?;
let state_hash = calculate_hash(
&state_ids_compressed.iter().map(|s| &s[..]).collect::<Vec<_>>(),
);
let state_hash =
calculate_hash(state_ids_compressed.iter().map(|s| &s[..]));
let (shortstatehash, already_existed) =
services().rooms.short.get_or_create_shortstatehash(&state_hash)?;

View file

@ -283,10 +283,7 @@ impl Service {
services().rooms.state.get_room_shortstatehash(room_id)?;
let state_hash = utils::calculate_hash(
&new_state_ids_compressed
.iter()
.map(|bytes| &bytes[..])
.collect::<Vec<_>>(),
new_state_ids_compressed.iter().map(|bytes| &bytes[..]),
);
let (new_shortstatehash, already_existed) =