Skip to content

Commit

Permalink
remove usage of strings.SplitN in entity_id.go
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcacheux committed Sep 21, 2024
1 parent b97517a commit 445bf94
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions comp/core/tagger/types/entity_id.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,24 +31,20 @@ type defaultEntityID string

// GetID implements EntityID#GetID
func (de defaultEntityID) GetID() string {
parts := strings.SplitN(string(de), separator, 2)

if len(parts) != 2 {
_, id, found := strings.Cut(string(de), separator)
if !found {
return ""
}

return parts[1]
return id
}

// GetPrefix implements EntityID#GetPrefix
func (de defaultEntityID) GetPrefix() EntityIDPrefix {
parts := strings.SplitN(string(de), separator, 2)

if len(parts) != 2 {
prefix, _, found := strings.Cut(string(de), separator)
if !found {
return ""
}

return EntityIDPrefix(parts[0])
return EntityIDPrefix(prefix)
}

// String implements EntityID#String
Expand Down

0 comments on commit 445bf94

Please sign in to comment.