nushell/crates/nu-json/src
Ian Manske cf9813cbf8
Refactor lines command (#11685)
# Description
This PR uses `str::lines` to simplify the `lines` command (and one other
section of code). This has two main benefits:
1. We no longer need to use regex to split on lines, as `str::lines`
splits on `\r\n` or `\n`.
2. We no longer need to handle blank empty lines at the end. E.g.,
`str::lines` results in `["text"]` for both `"test\n"` and `"text"`.

These changes give a slight boost to performance for the following
benchmarks:
1. lines of `Value::String`:
    ```nushell
    let data = open Cargo.lock
    1..10000 | each { $data | timeit { lines } } | math avg 
    ```
    current main: 392µs
    this PR: 270µs
2. lines of external stream:
    ```nushell
    1..10000 | each { open Cargo.lock | timeit { lines } } | math avg 
    ```
    current main: 794µs
    this PR: 489µs
2024-01-30 15:56:19 -06:00
..
builder.rs Remove old nushell/merge engine-q 2022-02-07 14:54:06 -05:00
de.rs Strict JSON parsing (#11592) 2024-01-30 08:10:19 -06:00
error.rs Use variable names directly in the format strings (#7906) 2023-01-29 19:37:54 -06:00
lib.rs Adds tab indentation option for JSON files. (#4705) 2022-03-03 13:15:13 -05:00
ser.rs Refactor lines command (#11685) 2024-01-30 15:56:19 -06:00
util.rs Remove 🆖 comments (#7877) 2023-01-27 08:48:31 -05:00
value.rs Use slices directly instead of &Vec (#10328) 2023-09-12 11:38:20 +08:00