From fbcbb77fc8c60ac3803607a3aaa33e47763b8f1f Mon Sep 17 00:00:00 2001 From: Cao Shufeng Date: Thu, 15 Jun 2017 17:32:31 +0800 Subject: [PATCH] Only do string trim when it's necessary This will enhance performance a little bit. --- pkg/auth/nodeidentifier/default.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/auth/nodeidentifier/default.go b/pkg/auth/nodeidentifier/default.go index 7375a275cf..5fa994c73e 100644 --- a/pkg/auth/nodeidentifier/default.go +++ b/pkg/auth/nodeidentifier/default.go @@ -50,8 +50,6 @@ func (defaultNodeIdentifier) NodeIdentity(u user.Info) (string, bool) { return "", false } - nodeName := strings.TrimPrefix(userName, nodeUserNamePrefix) - isNode := false for _, g := range u.GetGroups() { if g == user.NodesGroup { @@ -63,5 +61,6 @@ func (defaultNodeIdentifier) NodeIdentity(u user.Info) (string, bool) { return "", false } - return nodeName, isNode + nodeName := strings.TrimPrefix(userName, nodeUserNamePrefix) + return nodeName, true }