Skip to content

Commit

Permalink
refactor: improve json encoding performance
Browse files Browse the repository at this point in the history
  • Loading branch information
ssttehrani committed Jan 20, 2024
1 parent 0a93d87 commit 69d7de6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ replace github.com/projectcontour/contour => github.com/snapp-incubator/contour

require (
github.com/go-logr/logr v1.2.4
github.com/json-iterator/go v1.1.12
github.com/labstack/echo/v4 v4.11.2
github.com/onsi/ginkgo/v2 v2.13.0
github.com/onsi/gomega v1.28.0
Expand Down Expand Up @@ -56,7 +57,6 @@ require (
github.com/imdario/mergo v0.3.12 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/labstack/gommon v0.4.0 // indirect
github.com/magiconair/properties v1.8.7 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand Down
1 change: 0 additions & 1 deletion internal/webhook/validate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package webhook

import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
Expand Down
4 changes: 3 additions & 1 deletion internal/webhook/webhook.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package webhook

import (
"encoding/json"
"fmt"
"io"
"net"
"net/http"
"time"

jsoniter "github.com/json-iterator/go"
"github.com/labstack/echo/v4"
contourv1 "github.com/projectcontour/contour/apis/projectcontour/v1"
"github.com/snapp-incubator/contour-admission-webhook/internal/cache"
Expand All @@ -26,6 +26,8 @@ var (
codecFactory = serializer.NewCodecFactory(scheme)
deserializer = codecFactory.UniversalDeserializer()

json = jsoniter.ConfigCompatibleWithStandardLibrary

entryTtlSecond int

logger = ctrl.Log.WithName("webhook")
Expand Down

0 comments on commit 69d7de6

Please sign in to comment.