From: Jason Ish Date: Wed, 27 Apr 2022 16:16:02 +0000 (-0600) Subject: template(rust): convert transaction list to vecdeque X-Git-Tag: suricata-6.0.13~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5937a1cc86536aad53c3862dba4c269eb584ae09;p=thirdparty%2Fsuricata.git template(rust): convert transaction list to vecdeque Allows for more efficient removal from front of the list. Ticket: #5298 (cherry picked from commit e319d31c148a349e93bed2a68787684e39364d17) --- diff --git a/rust/src/applayertemplate/template.rs b/rust/src/applayertemplate/template.rs index 833d00c8e4..43502c5239 100644 --- a/rust/src/applayertemplate/template.rs +++ b/rust/src/applayertemplate/template.rs @@ -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, + transactions: VecDeque, 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