Skip to content

Commit

Permalink
feat: add small document (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
jensneuse authored Oct 6, 2023
1 parent 3358a84 commit fcbaaa9
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 11 additions & 0 deletions v2/pkg/ast/ast.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,17 @@ func NewDocument() *Document {
}
}

func NewSmallDocument() *Document {
return &Document{
BooleanValues: [2]BooleanValue{false, true},
Refs: make([][8]int, 48),
RefIndex: -1,
Index: Index{
nodes: make(map[uint64][]Node, 4),
},
}
}

func (d *Document) Reset() {
d.RootNodes = d.RootNodes[:0]
d.SchemaDefinitions = d.SchemaDefinitions[:0]
Expand Down
6 changes: 3 additions & 3 deletions v2/pkg/engine/resolve/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -698,9 +698,9 @@ func (l *Loader) loadWithSingleFlight(ctx *Context, source DataSource, identifie
}
data := maybeData.([]byte)
if shared {
out := res.getBuffer()
_, err = out.Write(data)
return out.Bytes(), err
out := make([]byte, len(data))
copy(out, data)
return out, err
}
return data, nil
}
Expand Down

0 comments on commit fcbaaa9

Please sign in to comment.