@@ -30,7 +30,7 @@ pub struct InfoTraffic {
3030}
3131
3232impl InfoTraffic {
33- pub fn refresh ( & mut self , msg : InfoTraffic ) {
33+ pub fn refresh ( & mut self , msg : & mut InfoTraffic ) {
3434 self . tot_data_info . refresh ( msg. tot_data_info ) ;
3535
3636 self . all_packets += msg. all_packets ;
@@ -39,30 +39,29 @@ impl InfoTraffic {
3939
4040 // it can happen they're equal due to dis-alignments in the PCAP timestamp
4141 if self . last_packet_timestamp . secs ( ) == msg. last_packet_timestamp . secs ( ) {
42- self . last_packet_timestamp . add_secs ( 1 ) ;
43- } else {
44- self . last_packet_timestamp = msg. last_packet_timestamp ;
42+ msg. last_packet_timestamp . add_secs ( 1 ) ;
4543 }
44+ self . last_packet_timestamp = msg. last_packet_timestamp ;
4645
47- for ( key, value) in msg. map {
46+ for ( key, value) in & msg. map {
4847 self . map
49- . entry ( key)
50- . and_modify ( |x| x. refresh ( & value) )
51- . or_insert ( value) ;
48+ . entry ( * key)
49+ . and_modify ( |x| x. refresh ( value) )
50+ . or_insert_with ( || value. clone ( ) ) ;
5251 }
5352
54- for ( key, value) in msg. services {
53+ for ( key, value) in & msg. services {
5554 self . services
56- . entry ( key)
57- . and_modify ( |x| x. refresh ( value) )
58- . or_insert ( value) ;
55+ . entry ( * key)
56+ . and_modify ( |x| x. refresh ( * value) )
57+ . or_insert ( * value) ;
5958 }
6059
61- for ( key, value) in msg. hosts {
60+ for ( key, value) in & msg. hosts {
6261 self . hosts
63- . entry ( key)
64- . and_modify ( |x| x. refresh ( & value) )
65- . or_insert ( value) ;
62+ . entry ( key. clone ( ) )
63+ . and_modify ( |x| x. refresh ( value) )
64+ . or_insert ( * value) ;
6665 }
6766 }
6867
0 commit comments