From e246dc8c19997baee8273856eb934ad435835949 Mon Sep 17 00:00:00 2001 From: lifubang Date: Mon, 16 Mar 2026 14:42:25 +0000 Subject: [PATCH] perf: eliminate redundant syscalls in "context.IsSet" Signed-off-by: lifubang --- context.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/context.go b/context.go index 3adf37e7b2..6e58cb4408 100644 --- a/context.go +++ b/context.go @@ -106,6 +106,9 @@ func (c *Context) IsSet(name string) bool { filePathValue := val.FieldByName("FilePath") if filePathValue.IsValid() { eachName(filePathValue.String(), func(filePath string) { + if filePath == "" { + return + } if _, err := os.Stat(filePath); err == nil { c.setFlags[name] = true return @@ -117,6 +120,9 @@ func (c *Context) IsSet(name string) bool { if envVarValue.IsValid() { eachName(envVarValue.String(), func(envVar string) { envVar = strings.TrimSpace(envVar) + if envVar == "" { + return + } if _, ok := syscall.Getenv(envVar); ok { c.setFlags[name] = true return