Skip to content

Commit

Permalink
chore: remove excessive spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
chenzhuoyu committed Aug 12, 2022
1 parent de2dc2c commit d4024be
Show file tree
Hide file tree
Showing 7 changed files with 258 additions and 258 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ import (
"reflect"
"github.com/bytedance/sonic"
"github.com/bytedance/sonic/option"
)
)

func init() {
var v HugeStruct
func init() {
var v HugeStruct
// For most large types (nesting depth <= 5)
err := sonic.Pretouch(reflect.TypeOf(v))
err := sonic.Pretouch(reflect.TypeOf(v))
// If the type is too deep nesting (nesting depth > 5),
// you can set compile recursive depth in Pretouch for better stability in JIT.
err := sonic.Pretouch(reflect.TypeOf(v), option.WithCompileRecursiveDepth(depth))
}
}
```

### Copy string
Expand Down
40 changes: 20 additions & 20 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ package sonic
import (
`io`
)
// Config is a combination of sonic/encoder.Options and sonic/decoder.Options
type Config struct {

// Config is a combination of sonic/encoder.Options and sonic/decoder.Options
type Config struct {
// EscapeHTML indicates encoder to escape all HTML characters
// after serializing into JSON (see https://pkg.go.dev/encoding/json#HTMLEscape).
// WARNING: This hurts performance A LOT, USE WITH CARE.
Expand Down Expand Up @@ -67,9 +67,9 @@ import (
// ValidateString indicates decoder to valid string values: decoder will return errors when
// invalid UTF-8 chars or unescaped control chars(\u0000-\u001f) in the string value of JSON.
ValidateString bool
}
}

var (
var (
// ConfigDefault is the default config of APIs, aiming at efficiency and safty.
ConfigDefault = Config{}.Froze()

Expand All @@ -85,13 +85,13 @@ import (
ConfigFastest = Config{
NoQuoteTextMarshaler: true,
}.Froze()
)
)


// API is a binding of specific config.
// This interface is inspired by github.com/json-iterator/go,
// and has same behaviors under equavilent config.
type API interface {
// API is a binding of specific config.
// This interface is inspired by github.com/json-iterator/go,
// and has same behaviors under equavilent config.
type API interface {
// MarshalToString returns the JSON encoding string of v
MarshalToString(v interface{}) (string, error)
// Marshal returns the JSON encoding bytes of v.
Expand All @@ -108,10 +108,10 @@ import (
NewDecoder(reader io.Reader) Decoder
// Valid validates the JSON-encoded bytes and reportes if it is valid
Valid(data []byte) bool
}
// Encoder encodes JSON into io.Writer
type Encoder interface {
}

// Encoder encodes JSON into io.Writer
type Encoder interface {
// Encode writes the JSON encoding of v to the stream, followed by a newline character.
Encode(val interface{}) error
// SetEscapeHTML specifies whether problematic HTML characters
Expand All @@ -122,10 +122,10 @@ import (
// as if indented by the package-level function Indent(dst, src, prefix, indent).
// Calling SetIndent("", "") disables indentation
SetIndent(prefix, indent string)
}
// Decoder decodes JSON from io.Read
type Decoder interface {
}

// Decoder decodes JSON from io.Read
type Decoder interface {
// Decode reads the next JSON-encoded value from its input and stores it in the value pointed to by v.
Decode(val interface{}) error
// Buffered returns a reader of the data remaining in the Decoder's buffer.
Expand All @@ -138,9 +138,9 @@ import (
More() bool
// UseNumber causes the Decoder to unmarshal a number into an interface{} as a Number instead of as a float64.
UseNumber()
}
}

// Marshal returns the JSON encoding bytes of v.
// Marshal returns the JSON encoding bytes of v.
func Marshal(val interface{}) ([]byte, error) {
return ConfigDefault.Marshal(val)
}
Expand Down

0 comments on commit d4024be

Please sign in to comment.