mirror of
https://github.com/nushell/nushell.git
synced 2024-12-25 08:29:07 +01:00
a43e66ef92
Closes #7572 by adding a cache for compiled regexes of type `Arc<Mutex<LruCache<String, Regex>>>` to `EngineState` . The cache is limited to 100 entries (limit chosen arbitrarily) and evicts least-recently-used items first. This PR makes a noticeable difference when using regexes for `color_config`, e.g.: ```bash #first set string formatting in config.nu like: string: { if $in =~ '^#\w{6}$' { $in } else { 'white' } }` # then try displaying and exploring a table with many strings # this is instant after the PR, but takes hundreds of milliseconds before ['#ff0033', '#0025ee', '#0087aa', 'string', '#4101ff', '#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff', '#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff', '#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff', '#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff','#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff','#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff','#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff','#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff','#ff0033', '#0025ee', '#0087aa', 'string', '#6103ff'] ``` ## New dependency (`lru`) This uses [the popular `lru` crate](https://lib.rs/crates/lru). The new dependency adds 19.8KB to a Linux release build of Nushell. I think this is OK, especially since the crate can be useful elsewhere in Nu.
38 lines
1.1 KiB
TOML
38 lines
1.1 KiB
TOML
[package]
|
|
authors = ["The Nushell Project Developers"]
|
|
description = "Nushell's internal protocols, including its abstract syntax tree"
|
|
repository = "https://github.com/nushell/nushell/tree/main/crates/nu-protocol"
|
|
edition = "2021"
|
|
license = "MIT"
|
|
name = "nu-protocol"
|
|
version = "0.73.1"
|
|
|
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
|
|
|
[dependencies]
|
|
nu-utils = { path = "../nu-utils", version = "0.73.1" }
|
|
nu-json = { path = "../nu-json", version = "0.73.1" }
|
|
|
|
byte-unit = "4.0.9"
|
|
chrono = { version="0.4.23", features= ["serde", "std"], default-features = false }
|
|
chrono-humanize = "0.2.1"
|
|
fancy-regex = "0.10.0"
|
|
indexmap = { version="1.7" }
|
|
lru = "0.8.1"
|
|
miette = { version = "5.1.0", features = ["fancy-no-backtrace"] }
|
|
num-format = "0.4.3"
|
|
serde = {version = "1.0.143", default-features = false }
|
|
serde_json = { version = "1.0", optional = true }
|
|
strum = "0.24"
|
|
strum_macros = "0.24"
|
|
sys-locale = "0.2.0"
|
|
thiserror = "1.0.31"
|
|
typetag = "0.1.8"
|
|
|
|
[features]
|
|
plugin = ["serde_json"]
|
|
|
|
[dev-dependencies]
|
|
serde_json = "1.0"
|
|
nu-test-support = { path = "../nu-test-support", version = "0.73.1" }
|