Skip to content

Commit 455a330

Browse files
server/gnome: Avoid extra Vec allocation
1 parent a6161dc commit 455a330

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

server/src/gnome/secret_exchange.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,9 @@ fn encode(map: &HashMap<&str, &[u8]>) -> String {
8282
// Converts a payload String into a HashMap
8383
fn decode(exchange: &str) -> Option<HashMap<&str, Vec<u8>>> {
8484
let (_, exchange) = exchange.split_once(PROTOCOL)?; // Remove PROTOCOL prefix
85-
let pairs = exchange.split("\n").collect::<Vec<_>>();
8685
let mut map: HashMap<&str, Vec<u8>> = HashMap::new();
8786

88-
for pair in pairs {
87+
for pair in exchange.split('\n') {
8988
if pair.is_empty() {
9089
// To avoid splitting an empty line (last new line)
9190
break;

0 commit comments

Comments
 (0)