Remove lots of redundant string allocations

This commit is contained in:
Jonas Platte 2021-04-05 21:44:21 +02:00
parent fe744c856f
commit dbe8c2ce19
No known key found for this signature in database
GPG key ID: CC154DE0E30B7C67
7 changed files with 87 additions and 95 deletions

View file

@ -217,7 +217,7 @@ impl Database {
}
pub async fn watch(&self, user_id: &UserId, device_id: &DeviceId) {
let userid_bytes = user_id.to_string().as_bytes().to_vec();
let userid_bytes = user_id.as_bytes().to_vec();
let mut userid_prefix = userid_bytes.clone();
userid_prefix.push(0xff);
@ -241,7 +241,7 @@ impl Database {
// Events for rooms we are in
for room_id in self.rooms.rooms_joined(user_id).filter_map(|r| r.ok()) {
let roomid_bytes = room_id.to_string().as_bytes().to_vec();
let roomid_bytes = room_id.as_bytes().to_vec();
let mut roomid_prefix = roomid_bytes.clone();
roomid_prefix.push(0xff);