mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 08:26:22 +02:00
Refactor source cache into CachedFile
struct (#12240)
# Description Get rid of two parallel `Vec`s in `StateDelta` and `EngineState`, that also duplicated span information. Use a struct with documenting fields. Also use `Arc<str>` and `Arc<[u8]>` for the allocations as they are never modified and cloned often (see #12229 for the first improvement). This also makes the representation more compact as no capacity is necessary. # User-Facing Changes API breakage on `EngineState`/`StateWorkingSet`/`StateDelta` that should not really affect plugin authors.
This commit is contained in:
committed by
GitHub
parent
63335e99ae
commit
ec528c0626
@ -43,13 +43,15 @@ impl Command for ViewFiles {
|
||||
) -> Result<PipelineData, ShellError> {
|
||||
let mut records = vec![];
|
||||
|
||||
for (file, start, end) in engine_state.files() {
|
||||
for file in engine_state.files() {
|
||||
let start = file.covered_span.start;
|
||||
let end = file.covered_span.end;
|
||||
records.push(Value::record(
|
||||
record! {
|
||||
"filename" => Value::string(&**file, call.head),
|
||||
"start" => Value::int(*start as i64, call.head),
|
||||
"end" => Value::int(*end as i64, call.head),
|
||||
"size" => Value::int(*end as i64 - *start as i64, call.head),
|
||||
"filename" => Value::string(&*file.name, call.head),
|
||||
"start" => Value::int(start as i64, call.head),
|
||||
"end" => Value::int(end as i64, call.head),
|
||||
"size" => Value::int(end as i64 - start as i64, call.head),
|
||||
},
|
||||
call.head,
|
||||
));
|
||||
|
Reference in New Issue
Block a user