From 1791d51fd0d6cd8337fe2fee39b4e449d61c8d24 Mon Sep 17 00:00:00 2001 From: Ramkumar Chinchani Date: Fri, 29 Sep 2023 21:50:30 +0000 Subject: [PATCH] fix: replace with faster JSON encoding Signed-off-by: Ramkumar Chinchani --- pkg/meta/boltdb/boltdb.go | 5 ++++- pkg/meta/dynamodb/dynamodb.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/meta/boltdb/boltdb.go b/pkg/meta/boltdb/boltdb.go index ca14e456da..38394eb402 100644 --- a/pkg/meta/boltdb/boltdb.go +++ b/pkg/meta/boltdb/boltdb.go @@ -2,12 +2,13 @@ package boltdb import ( "context" - "encoding/json" "errors" "fmt" "strings" "time" + jsoniter "github.com/json-iterator/go" + godigest "github.com/opencontainers/go-digest" ispec "github.com/opencontainers/image-spec/specs-go/v1" "go.etcd.io/bbolt" @@ -29,6 +30,8 @@ type BoltDB struct { Log log.Logger } +var json = jsoniter.ConfigCompatibleWithStandardLibrary + func New(boltDB *bbolt.DB, log log.Logger) (*BoltDB, error) { err := boltDB.Update(func(transaction *bbolt.Tx) error { versionBuck, err := transaction.CreateBucketIfNotExists([]byte(VersionBucket)) diff --git a/pkg/meta/dynamodb/dynamodb.go b/pkg/meta/dynamodb/dynamodb.go index d96c2b1dfa..b5f62a4a41 100644 --- a/pkg/meta/dynamodb/dynamodb.go +++ b/pkg/meta/dynamodb/dynamodb.go @@ -2,12 +2,13 @@ package dynamodb import ( "context" - "encoding/json" "errors" "fmt" "strings" "time" + jsoniter "github.com/json-iterator/go" + "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/feature/dynamodb/attributevalue" "github.com/aws/aws-sdk-go-v2/service/dynamodb" @@ -25,6 +26,8 @@ import ( reqCtx "zotregistry.io/zot/pkg/requestcontext" ) +var json = jsoniter.ConfigCompatibleWithStandardLibrary + var errMetaDB = errors.New("metadb: error while constructing manifest meta") type DynamoDB struct {