Skip to content

Commit

Permalink
chore: improve allocations (#655)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergiy <818351+devsergiy@users.noreply.github.com>
  • Loading branch information
jensneuse and devsergiy authored Nov 2, 2023
1 parent 25af8cf commit e015015
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 551 deletions.
2 changes: 1 addition & 1 deletion v2/pkg/astparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ParseGraphqlDocumentString(input string) (ast.Document, operationreport.Rep
// Instead create a parser as well as AST objects and re-use them.
func ParseGraphqlDocumentBytes(input []byte) (ast.Document, operationreport.Report) {
parser := NewParser()
doc := *ast.NewDocument()
doc := *ast.NewSmallDocument()
doc.Input.ResetInputBytes(input)
report := operationreport.Report{}
parser.Parse(&doc, &report)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (p *Planner) UpstreamSchema(dataSourceConfig plan.DataSourceConfiguration)
panic(err)
}

definition := ast.NewDocument()
definition := ast.NewSmallDocument()
definitionParser := astparser.NewParser()
report := &operationreport.Report{}

Expand Down Expand Up @@ -738,7 +738,7 @@ func (p *Planner) EnterArgument(_ int) {

func (p *Planner) EnterDocument(_, _ *ast.Document) {
if p.upstreamOperation == nil {
p.upstreamOperation = ast.NewDocument()
p.upstreamOperation = ast.NewSmallDocument()
} else {
p.upstreamOperation.Reset()
}
Expand All @@ -763,7 +763,7 @@ func (p *Planner) EnterDocument(_, _ *ast.Document) {

p.upstreamDefinition = nil
if p.config.UpstreamSchema != "" {
p.upstreamDefinition = ast.NewDocument()
p.upstreamDefinition = ast.NewSmallDocument()
p.upstreamDefinition.Input.ResetInputString(p.config.UpstreamSchema)
parser := astparser.NewParser()
var report operationreport.Report
Expand Down Expand Up @@ -1354,8 +1354,8 @@ func (p *Planner) printOperation() []byte {
rawQuery := buf.Bytes()

// create empty operation and definition documents
operation := ast.NewDocument()
definition := ast.NewDocument()
operation := ast.NewSmallDocument()
definition := ast.NewSmallDocument()
report := &operationreport.Report{}
operationParser := astparser.NewParser()
definitionParser := astparser.NewParser()
Expand Down
Loading

0 comments on commit e015015

Please sign in to comment.