From: Jason Ish Date: Wed, 27 Apr 2022 15:38:51 +0000 (-0600) Subject: http2: convert transaction list to vecdeque X-Git-Tag: suricata-7.0.0-beta1~665 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2db84726ad3445a0b55ca145489103483f61c6b0;p=thirdparty%2Fsuricata.git http2: convert transaction list to vecdeque Allows for more efficient removal from front of the list. Ticket: #5296 --- diff --git a/rust/src/http2/http2.rs b/rust/src/http2/http2.rs index 135bad0849..7a64c17c4f 100644 --- a/rust/src/http2/http2.rs +++ b/rust/src/http2/http2.rs @@ -1,4 +1,4 @@ -/* Copyright (C) 2020 Open Information Security Foundation +/* Copyright (C) 2020-2022 Open Information Security Foundation * * You can copy, redistribute or modify this Program under the terms of * the GNU General Public License version 2 as published by the Free @@ -27,6 +27,7 @@ use crate::filecontainer::*; use crate::filetracker::*; use nom7::Err; use std; +use std::collections::VecDeque; use std::ffi::CString; use std::fmt; use std::io; @@ -397,7 +398,7 @@ pub struct HTTP2State { response_frame_size: u32, dynamic_headers_ts: HTTP2DynTable, dynamic_headers_tc: HTTP2DynTable, - transactions: Vec, + transactions: VecDeque, progress: HTTP2ConnectionState, pub files: Files, } @@ -423,7 +424,7 @@ impl HTTP2State { // a variable number of dynamic headers dynamic_headers_ts: HTTP2DynTable::new(), dynamic_headers_tc: HTTP2DynTable::new(), - transactions: Vec::new(), + transactions: VecDeque::new(), progress: HTTP2ConnectionState::Http2StateInit, files: Files::default(), } @@ -538,8 +539,8 @@ impl HTTP2State { self.tx_id += 1; tx.tx_id = self.tx_id; tx.state = HTTP2TransactionState::HTTP2StateGlobal; - self.transactions.push(tx); - return self.transactions.last_mut().unwrap(); + self.transactions.push_back(tx); + return self.transactions.back_mut().unwrap(); } pub fn find_or_create_tx( @@ -591,8 +592,8 @@ impl HTTP2State { } } } - self.transactions.push(tx); - return self.transactions.last_mut().unwrap(); + self.transactions.push_back(tx); + return self.transactions.back_mut().unwrap(); } }