commit 3abc1e5e460738f302e48ea7f369c1466fd044ca
parent cce21232cc83060a53ecb3a7c30d7f6fbfd7a529
Author: Charlie Stanton <charlie@shtanton.xyz>
Date: Tue, 25 Apr 2023 10:20:15 +0100
Make state.path immutable so it can be a reference instead of copied, improving performance
Diffstat:
2 files changed, 1 insertion(+), 12 deletions(-)
diff --git a/main/command.go b/main/command.go
@@ -116,5 +116,5 @@ func (cmd SwapPathCommand) exec(state *ProgramState) {
type AppendPathCommand struct {}
func (cmd AppendPathCommand) exec(state *ProgramState) {
- state.path = append(state.path, state.value...)
+ state.path = walk.ConcatData(state.path, state.value)
}
\ No newline at end of file
diff --git a/walk/walk.go b/walk/walk.go
@@ -333,17 +333,6 @@ func (in *JSONIn) readString(out []Atom) []Atom {
}
func (in *JSONIn) Read() (WalkItem, error) {
- item, err := in.read()
- if err != nil {
- return item, err
- }
- return WalkItem {
- Value: item.Value,
- Path: append([]Atom{}, item.Path...),
- }, err
-}
-
-func (in *JSONIn) read() (WalkItem, error) {
restart:
// TODO: Escaping
// TODO: Don't allow trailing commas