mirror of
https://github.com/nftables-rs/nftables-rs.git
synced 2026-10-19 16:01:31 +00:00
feat!: reduce stack usage by selectively wrapping large values in Box
This evens out some of the large enums' sizes (e.g. Expression and Statement's) from over 200 bytes to <=144. Further reduction could be done, as this commit only changes the obvious ones for now. Also moves BinaryOperation's Box up one level so it only uses one Box.
This commit is contained in:
committed by
Jasper Wiegratz
parent
8ddb5ff132
commit
583b2d58cb
+6
-6
@@ -14,7 +14,7 @@ pub enum Expression {
|
||||
Boolean(bool),
|
||||
/// List expressions are constructed by plain arrays containing of an arbitrary number of expressions.
|
||||
List(Cow<'static, [Expression]>),
|
||||
BinaryOperation(BinaryOperation),
|
||||
BinaryOperation(Box<BinaryOperation>),
|
||||
Range(Range),
|
||||
|
||||
Named(NamedExpression),
|
||||
@@ -327,23 +327,23 @@ pub enum FibFlag {
|
||||
pub enum BinaryOperation {
|
||||
#[serde(rename = "&")]
|
||||
/// Binary AND (`&`)
|
||||
AND(Box<Expression>, Box<Expression>),
|
||||
AND(Expression, Expression),
|
||||
|
||||
#[serde(rename = "|")]
|
||||
/// Binary OR (`|`)
|
||||
OR(Box<Expression>, Box<Expression>),
|
||||
OR(Expression, Expression),
|
||||
|
||||
#[serde(rename = "^")]
|
||||
/// Binary XOR (`^`)
|
||||
XOR(Box<Expression>, Box<Expression>),
|
||||
XOR(Expression, Expression),
|
||||
|
||||
#[serde(rename = "<<")]
|
||||
/// Left shift (`<<`)
|
||||
LSHIFT(Box<Expression>, Box<Expression>),
|
||||
LSHIFT(Expression, Expression),
|
||||
|
||||
#[serde(rename = ">>")]
|
||||
/// Right shift (`>>`)
|
||||
RSHIFT(Box<Expression>, Box<Expression>),
|
||||
RSHIFT(Expression, Expression),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
+3
-3
@@ -140,9 +140,9 @@ pub enum FlushObject {
|
||||
/// A chain to flush (i.e., remove all rules from chain).
|
||||
Chain(Chain),
|
||||
/// A set to flush (i.e., remove all elements from set).
|
||||
Set(Set),
|
||||
Set(Box<Set>),
|
||||
/// A map to flush (i.e., remove all elements from map).
|
||||
Map(Map),
|
||||
Map(Box<Map>),
|
||||
/// A meter to flush.
|
||||
Meter(Meter),
|
||||
/// Flush the live ruleset (i.e., remove all elements from live ruleset).
|
||||
@@ -774,7 +774,7 @@ pub enum LimitUnit {
|
||||
pub struct Meter {
|
||||
pub name: Cow<'static, str>,
|
||||
pub key: Expression,
|
||||
pub stmt: Statement,
|
||||
pub stmt: Box<Statement>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, Serialize, Deserialize)]
|
||||
|
||||
Reference in New Issue
Block a user