Skip to content

Commit

Permalink
perf: all: use io.WriteString instead of byteslice(string) conversion (
Browse files Browse the repository at this point in the history
  • Loading branch information
odeke-em authored Jul 6, 2023
1 parent acce343 commit 4b557c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions collections/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (m Map[K, V]) importGenesis(ctx context.Context, reader io.Reader) error {
}

func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error {
_, err := writer.Write([]byte("["))
_, err := io.WriteString(writer, "[")
if err != nil {
return err
}
Expand All @@ -48,7 +48,7 @@ func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error {
// add a comma before encoding the object
// for all objects besides the first one.
if !first {
_, err = writer.Write([]byte(","))
_, err = io.WriteString(writer, ",")
if err != nil {
return err
}
Expand Down Expand Up @@ -91,7 +91,7 @@ func (m Map[K, V]) exportGenesis(ctx context.Context, writer io.Writer) error {
}
}

_, err = writer.Write([]byte("]"))
_, err = io.WriteString(writer, "]")
return err
}

Expand Down Expand Up @@ -148,6 +148,6 @@ func (m Map[K, V]) doDecodeJSON(reader io.Reader, onEntry func(key K, value V) e
}

func (m Map[K, V]) defaultGenesis(writer io.Writer) error {
_, err := writer.Write([]byte(`[]`))
_, err := io.WriteString(writer, `[]`)
return err
}
2 changes: 1 addition & 1 deletion orm/encoding/ormfield/string.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (s NonTerminalStringCodec) Encode(value protoreflect.Value, w io.Writer) er
return fmt.Errorf("illegal null terminator found in index string: %s", str)
}
}
_, err := w.Write([]byte(str))
_, err := w.Write(bz)
if err != nil {
return err
}
Expand Down

0 comments on commit 4b557c9

Please sign in to comment.