]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
http2: convert transaction list to vecdeque
authorJason Ish <jason.ish@oisf.net>
Wed, 27 Apr 2022 15:38:51 +0000 (09:38 -0600)
committerVictor Julien <vjulien@oisf.net>
Sat, 10 Jun 2023 08:01:06 +0000 (10:01 +0200)
Allows for more efficient removal from front of the list.

Ticket: #5296
(cherry picked from commit 2db84726ad3445a0b55ca145489103483f61c6b0)

rust/src/http2/http2.rs

index 6917e054cbce0bedaeba3928c1b1df748794e485..ee285ad1eebb69f09433111e046a5356c358e955 100644 (file)
@@ -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
@@ -29,6 +29,7 @@ use crate::filetracker::*;
 use nom;
 use std;
 use std::ffi::{CStr, CString};
+use std::collections::VecDeque;
 use std::fmt;
 use std::io;
 use std::mem::transmute;
@@ -379,7 +380,7 @@ pub struct HTTP2State {
     response_frame_size: u32,
     dynamic_headers_ts: HTTP2DynTable,
     dynamic_headers_tc: HTTP2DynTable,
-    transactions: Vec<HTTP2Transaction>,
+    transactions: VecDeque<HTTP2Transaction>,
     progress: HTTP2ConnectionState,
     pub files: HTTP2Files,
 }
@@ -395,7 +396,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: HTTP2Files::new(),
         }
@@ -474,8 +475,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(
@@ -515,8 +516,8 @@ impl HTTP2State {
             tx.tx_id = self.tx_id;
             tx.stream_id = sid;
             tx.state = HTTP2TransactionState::HTTP2StateOpen;
-            self.transactions.push(tx);
-            return self.transactions.last_mut().unwrap();
+            self.transactions.push_back(tx);
+            return self.transactions.back_mut().unwrap();
         }
     }