Skip to content

Commit

Permalink
martian/context: store id as string
Browse files Browse the repository at this point in the history
This does not require to convert id on every call to ID().
  • Loading branch information
Choraden committed Aug 28, 2023
1 parent 015f681 commit b0de7ec
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internal/martian/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
// a single connection.
type Context struct {
session *Session
id uint64
id string

mu sync.RWMutex
vals map[string]any
Expand Down Expand Up @@ -186,7 +186,7 @@ func (ctx *Context) Session() *Session {

// ID returns the context ID.
func (ctx *Context) ID() string {
return strconv.FormatUint(ctx.id, 10)
return ctx.id
}

// Get takes key and returns the associated value from the context.
Expand Down Expand Up @@ -255,6 +255,6 @@ func init() {
func withSession(s *Session) *Context {
return &Context{
session: s,
id: nextID.Add(1),
id: strconv.FormatUint(nextID.Add(1), 10),
}
}

0 comments on commit b0de7ec

Please sign in to comment.