Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance: increase perfomance when build with -tag release #410

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions pkg/build/norelease.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build !release

package build

func initReleaseOptions() {
CheckChildAlreadyExists = true
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can skip option.go and have this in norelease.go

const CheckChildAlreadyExists = true

and this in release.go

const CheckChildAlreadyExists = false

9 changes: 9 additions & 0 deletions pkg/build/options.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package build

var (
CheckChildAlreadyExists = true
)

func init() {
initReleaseOptions()
}
7 changes: 7 additions & 0 deletions pkg/build/release.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
//go:build release

package build

func initReleaseOptions() {
CheckChildAlreadyExists = false
}
3 changes: 2 additions & 1 deletion pkg/decode/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"bytes"
"context"
"fmt"
"github.com/wader/fq/pkg/build"
"io"
"math/big"
"regexp"
Expand Down Expand Up @@ -720,7 +721,7 @@ func (d *D) AddChild(v *Value) {

switch fv := d.Value.V.(type) {
case *Compound:
if !fv.IsArray {
if build.CheckChildAlreadyExists && !fv.IsArray {
for _, ff := range fv.Children {
if ff.Name == v.Name {
d.Fatalf("%q already exist in struct %s", v.Name, d.Value.Name)
Expand Down