mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 15:06:03 +02:00
Box ImportPattern
in Expr
(#12568)
# Description Adds a `Box` around the `ImportPattern` in `Expr` which decreases the size of `Expr` from 152 to 64 bytes (and `Expression` from 216 to 128 bytes). This seems to speed up parsing a little bit according to the benchmarks (main is top, PR is bottom): ``` benchmarks fastest │ slowest │ median │ mean │ samples │ iters benchmarks fastest │ slowest │ median │ mean │ samples │ iters ├─ parser_benchmarks │ │ │ │ │ ├─ parser_benchmarks │ │ │ │ │ │ ├─ parse_default_config_file 2.287 ms │ 4.532 ms │ 2.311 ms │ 2.437 ms │ 100 │ 100 │ ├─ parse_default_config_file 2.255 ms │ 2.781 ms │ 2.281 ms │ 2.312 ms │ 100 │ 100 │ ╰─ parse_default_env_file 421.8 µs │ 824.6 µs │ 494.3 µs │ 527.5 µs │ 100 │ 100 │ ╰─ parse_default_env_file 402 µs │ 486.6 µs │ 414.8 µs │ 416.2 µs │ 100 │ 100 ```
This commit is contained in:
@ -46,7 +46,7 @@ pub enum Expr {
|
||||
String(String),
|
||||
CellPath(CellPath),
|
||||
FullCellPath(Box<FullCellPath>),
|
||||
ImportPattern(ImportPattern),
|
||||
ImportPattern(Box<ImportPattern>),
|
||||
Overlay(Option<BlockId>), // block ID of the overlay's origin module
|
||||
Signature(Box<Signature>),
|
||||
StringInterpolation(Vec<Expression>),
|
||||
|
@ -110,7 +110,7 @@ impl Expression {
|
||||
|
||||
pub fn as_import_pattern(&self) -> Option<ImportPattern> {
|
||||
match &self.expr {
|
||||
Expr::ImportPattern(pattern) => Some(pattern.clone()),
|
||||
Expr::ImportPattern(pattern) => Some(*pattern.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user