use json unmarshal/marshal from jsoniter in hotpaths (#12269)

This commit is contained in:
Harshavardhana
2021-05-11 02:02:32 -07:00
committed by GitHub
parent 14849b9b2c
commit b81fada834
8 changed files with 16 additions and 4 deletions

View File

@@ -21,11 +21,11 @@ import (
"bytes"
"crypto/rand"
"encoding/binary"
"encoding/json"
"errors"
"fmt"
"io"
jsoniter "github.com/json-iterator/go"
"github.com/minio/minio/pkg/fips"
"github.com/minio/minio/pkg/kms"
"github.com/secure-io/sio-go"
@@ -88,6 +88,7 @@ func Encrypt(KMS kms.KMS, plaintext io.Reader, context kms.Context) (io.Reader,
header [5]byte
buffer bytes.Buffer
)
var json = jsoniter.ConfigCompatibleWithStandardLibrary
metadata, err := json.Marshal(encryptedObject{
KeyID: key.KeyID,
KMSKey: key.Ciphertext,
@@ -139,6 +140,7 @@ func Decrypt(KMS kms.KMS, ciphertext io.Reader, context kms.Context) (io.Reader,
if _, err := io.ReadFull(ciphertext, metadataBuffer); err != nil {
return nil, err
}
var json = jsoniter.ConfigCompatibleWithStandardLibrary
if err := json.Unmarshal(metadataBuffer, &metadata); err != nil {
return nil, err
}