mirror of
https://github.com/nushell/nushell.git
synced 2025-07-06 17:40:17 +02:00
Refactor ansi stripping into nu-utils
functions (#6966)
Allows use of slightly optimized variants that check if they have to use the heavier vte parser. Tries to avoid unnnecessary allocations. Initial performance characteristics proven out in #4378. Also reduces boilerplate with right-ward drift.
This commit is contained in:
committed by
GitHub
parent
b9195c2668
commit
2c4048eb43
@ -248,14 +248,8 @@ fn nu_value_to_string(value: Value, separator: &str, config: &Config) -> String
|
||||
}
|
||||
Value::String { val, .. } => {
|
||||
// don't store ansi escape sequences in the database
|
||||
let stripped = {
|
||||
match strip_ansi_escapes::strip(&val) {
|
||||
Ok(item) => String::from_utf8(item).unwrap_or(val),
|
||||
Err(_) => val,
|
||||
}
|
||||
};
|
||||
// escape single quotes
|
||||
stripped.replace('\'', "''")
|
||||
nu_utils::strip_ansi_unlikely(&val).replace('\'', "''")
|
||||
}
|
||||
Value::List { vals: val, .. } => val
|
||||
.iter()
|
||||
|
Reference in New Issue
Block a user