Skip to content

Commit 4038f08

Browse files
committed
Factor event generation
Which should save one borrow each time.
1 parent db52458 commit 4038f08

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

  • neqo-transport/src/connection

neqo-transport/src/connection/mod.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2096,13 +2096,17 @@ impl Connection {
20962096
.migrate(&path, force, now, &mut self.stats.borrow_mut())
20972097
{
20982098
self.loss_recovery.migrate();
2099-
let local = path.borrow().local_address();
2100-
let remote = path.borrow().remote_address();
2101-
self.events.path_migrated(local, remote);
2099+
self.path_migrated(&path);
21022100
}
21032101
Ok(())
21042102
}
21052103

2104+
fn path_migrated(&mut self, path: &PathRef) {
2105+
let p = path.borrow();
2106+
self.events
2107+
.path_migrated(p.local_address(), p.remote_address());
2108+
}
2109+
21062110
fn migrate_to_preferred_address(&mut self, now: Instant) -> Res<()> {
21072111
let spa: Option<(tparams::PreferredAddress, ConnectionIdEntry<Srt>)> = if matches!(
21082112
self.conn_params.get_preferred_address(),
@@ -2171,9 +2175,7 @@ impl Connection {
21712175
self.paths
21722176
.handle_migration(path, remote, now, &mut self.stats.borrow_mut());
21732177
if !was_primary {
2174-
let local = path.borrow().local_address();
2175-
let remote_addr = path.borrow().remote_address();
2176-
self.events.path_migrated(local, remote_addr);
2178+
self.path_migrated(path);
21772179
}
21782180
} else {
21792181
qinfo!(
@@ -3392,9 +3394,7 @@ impl Connection {
33923394
// This PATH_RESPONSE enabled migration; tell loss recovery.
33933395
self.loss_recovery.migrate();
33943396
if let Some(primary) = self.paths.primary() {
3395-
let local = primary.borrow().local_address();
3396-
let remote = primary.borrow().remote_address();
3397-
self.events.path_migrated(local, remote);
3397+
self.path_migrated(&primary);
33983398
}
33993399
}
34003400
}

0 commit comments

Comments
 (0)