perf: simplify method signatures and reduce clone across multiple files (#1663)

This commit is contained in:
Tunglies
2025-12-09 16:47:57 +08:00
committed by GitHub
parent 2bc51daa98
commit fe4dff5df0
33 changed files with 62 additions and 81 deletions
+1 -1
View File
@@ -67,7 +67,7 @@ impl RequestHandler for CatalogRequestHandler {
pub fn build_authority(domain: &str, records: &[Record]) -> Result<InMemoryAuthority> {
let zone = rr::Name::from_str(domain)?;
let mut authority = InMemoryAuthority::empty(zone.clone(), ZoneType::Primary, false);
let mut authority = InMemoryAuthority::empty(zone, ZoneType::Primary, false);
for record in records.iter() {
let r = record.try_into()?;
authority.upsert_mut(r, 0);
+3 -3
View File
@@ -73,7 +73,7 @@ impl IpProxy {
let tcp_proxy = TcpProxy::new(peer_manager.clone(), NatDstTcpConnector {});
let icmp_proxy = IcmpProxy::new(global_ctx.clone(), peer_manager.clone())
.with_context(|| "create icmp proxy failed")?;
let udp_proxy = UdpProxy::new(global_ctx.clone(), peer_manager.clone())
let udp_proxy = UdpProxy::new(global_ctx.clone(), peer_manager)
.with_context(|| "create udp proxy failed")?;
Ok(IpProxy {
tcp_proxy,
@@ -551,7 +551,7 @@ impl Instance {
let peer_manager = Arc::new(PeerManager::new(
RouteAlgoType::Ospf,
global_ctx.clone(),
peer_packet_sender.clone(),
peer_packet_sender,
));
peer_manager.set_allow_loopback_tunnel(false);
@@ -617,7 +617,7 @@ impl Instance {
self.conn_manager.clone()
}
async fn add_initial_peers(&mut self) -> Result<(), Error> {
async fn add_initial_peers(&self) -> Result<(), Error> {
for peer in self.global_ctx.config.get_peers().iter() {
self.get_conn_manager()
.add_connector_by_url(peer.uri.clone())
+1 -1
View File
@@ -366,7 +366,7 @@ impl VirtualNic {
Ok(())
}
async fn create_tun(&mut self) -> Result<tun::platform::Device, Error> {
async fn create_tun(&self) -> Result<tun::platform::Device, Error> {
let mut config = Configuration::default();
config.layer(Layer::L3);