use swap_remove
instead of remove
in a few places
`swap_remove` is faster if we don't care about the order (O(1)) Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
parent
b63937af0b
commit
f6fa2a4f65
3 changed files with 4 additions and 4 deletions
|
@ -247,13 +247,13 @@ fn room_available_servers(
|
|||
.iter()
|
||||
.position(|server_name| server_is_ours(server_name))
|
||||
{
|
||||
servers.remove(server_index);
|
||||
servers.swap_remove(server_index);
|
||||
servers.insert(0, services().globals.server_name().to_owned());
|
||||
} else if let Some(alias_server_index) = servers
|
||||
.iter()
|
||||
.position(|server| server == room_alias.server_name())
|
||||
{
|
||||
servers.remove(alias_server_index);
|
||||
servers.swap_remove(alias_server_index);
|
||||
servers.insert(0, room_alias.server_name().into());
|
||||
}
|
||||
|
||||
|
|
|
@ -1922,7 +1922,7 @@ pub(crate) async fn get_room_information_route(
|
|||
.iter()
|
||||
.position(|server| server == services().globals.server_name())
|
||||
{
|
||||
servers.remove(server_index);
|
||||
servers.swap_remove(server_index);
|
||||
servers.insert(0, services().globals.server_name().to_owned());
|
||||
}
|
||||
|
||||
|
|
|
@ -1078,7 +1078,7 @@ impl Service {
|
|||
.into_iter()
|
||||
.position(|server_name| server_is_ours(&server_name))
|
||||
{
|
||||
servers.remove(server_index);
|
||||
servers.swap_remove(server_index);
|
||||
}
|
||||
|
||||
servers.sort_unstable();
|
||||
|
|
Loading…
Add table
Reference in a new issue