]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
template(rust): convert transaction list to vecdeque
authorJason Ish <jason.ish@oisf.net>
Wed, 27 Apr 2022 16:16:02 +0000 (10:16 -0600)
committerVictor Julien <vjulien@oisf.net>
Sat, 30 Apr 2022 05:58:21 +0000 (07:58 +0200)
Allows for more efficient removal from front of the list.

Ticket: #5298

rust/src/applayertemplate/template.rs

index 2e7234c76f496527e88392583ffd3a674f417d6d..a0ec9a34afc18856079876967d534c4f5a0d3240 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (C) 2018-2020 Open Information Security Foundation
+/* Copyright (C) 2018-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
@@ -16,6 +16,7 @@
  */
 
 use std;
+use std::collections::VecDeque;
 use crate::core::{ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
 use crate::applayer::{self, *};
 use std::ffi::CString;
@@ -54,7 +55,7 @@ impl Transaction for TemplateTransaction {
 
 pub struct TemplateState {
     tx_id: u64,
-    transactions: Vec<TemplateTransaction>,
+    transactions: VecDeque<TemplateTransaction>,
     request_gap: bool,
     response_gap: bool,
 }
@@ -73,7 +74,7 @@ impl TemplateState {
     pub fn new() -> Self {
         Self {
             tx_id: 0,
-            transactions: Vec::new(),
+            transactions: VecDeque::new(),
             request_gap: false,
             response_gap: false,
         }
@@ -150,7 +151,7 @@ impl TemplateState {
                     SCLogNotice!("Request: {}", request);
                     let mut tx = self.new_tx();
                     tx.request = Some(request);
-                    self.transactions.push(tx);
+                    self.transactions.push_back(tx);
                 },
                 Err(nom::Err::Incomplete(_)) => {
                     // Not enough data. This parser doesn't give us a good indication