Skip to content

Commit

Permalink
Replace fmt.Sprintf with strconv (#254)
Browse files Browse the repository at this point in the history
  • Loading branch information
hackerwins authored Oct 5, 2021
1 parent 3a3ee81 commit dc3b660
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pkg/document/json/rga_tree_split.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package json

import (
"fmt"
"strconv"
"strings"

"github.com/yorkie-team/yorkie/internal/log"
Expand Down Expand Up @@ -91,7 +92,7 @@ func (t *RGATreeSplitNodeID) hasSameCreatedAt(id *RGATreeSplitNodeID) bool {
}

func (t *RGATreeSplitNodeID) key() string {
return fmt.Sprintf("%s:%d", t.createdAt.Key(), t.offset)
return t.CreatedAt().Key() + ":" + strconv.FormatUint(uint64(t.offset), 10)
}

// RGATreeSplitNodePos is the position of the text inside the node.
Expand Down
14 changes: 10 additions & 4 deletions pkg/document/time/ticket.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package time
import (
"fmt"
"math"
"strconv"
)

const (
Expand Down Expand Up @@ -81,12 +82,17 @@ func (t *Ticket) AnnotatedString() string {
// Key returns the key string for this Ticket.
func (t *Ticket) Key() string {
if t.actorID == nil {
return fmt.Sprintf("%d:%d:", t.lamport, t.delimiter)
return strconv.FormatUint(t.lamport, 10) +
":" +
strconv.FormatUint(uint64(t.delimiter), 10) +
":"
}

return fmt.Sprintf(
"%d:%d:%s", t.lamport, t.delimiter, t.actorID.String(),
)
return strconv.FormatUint(t.lamport, 10) +
":" +
strconv.FormatUint(uint64(t.delimiter), 10) +
":" +
t.actorID.String()
}

// Lamport returns the lamport value.
Expand Down

0 comments on commit dc3b660

Please sign in to comment.