]> 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, 10 Jun 2023 08:01:06 +0000 (10:01 +0200)
Allows for more efficient removal from front of the list.

Ticket: #5298
(cherry picked from commit e319d31c148a349e93bed2a68787684e39364d17)

rust/src/applayertemplate/template.rs

index 833d00c8e49d825716bbb3979621e999cd9ebfe6..43502c52390c949214bbd31b932804853ec911f5 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
@@ -18,6 +18,7 @@
 use std;
 use crate::core::{self, ALPROTO_UNKNOWN, AppProto, Flow, IPPROTO_TCP};
 use std::mem::transmute;
+use std::collections::VecDeque;
 use crate::applayer::{self, *};
 use std::ffi::CString;
 use nom;
@@ -65,7 +66,7 @@ impl Drop for TemplateTransaction {
 
 pub struct TemplateState {
     tx_id: u64,
-    transactions: Vec<TemplateTransaction>,
+    transactions: VecDeque<TemplateTransaction>,
     request_gap: bool,
     #[allow(dead_code)]
     response_gap: bool,
@@ -75,7 +76,7 @@ impl TemplateState {
     pub fn new() -> Self {
         Self {
             tx_id: 0,
-            transactions: Vec::new(),
+            transactions: VecDeque::new(),
             request_gap: false,
             response_gap: false,
         }
@@ -152,7 +153,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