From 4ff3975c5a636f42a81785aeb8eb43dde541124f Mon Sep 17 00:00:00 2001 From: Qiu shao Date: Wed, 10 Dec 2025 22:46:26 +0800 Subject: [PATCH] perf(config): optimize getfullname (#5328) Co-authored-by: qiuwenhao --- core/conf/config.go | 2 +- core/conf/config_test.go | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/core/conf/config.go b/core/conf/config.go index 0ca8eccf3..7850c9ba4 100644 --- a/core/conf/config.go +++ b/core/conf/config.go @@ -368,5 +368,5 @@ func getFullName(parent, child string) string { return child } - return strings.Join([]string{parent, child}, ".") + return parent + "." + child } diff --git a/core/conf/config_test.go b/core/conf/config_test.go index 11b05294c..dd9247224 100644 --- a/core/conf/config_test.go +++ b/core/conf/config_test.go @@ -1377,3 +1377,23 @@ func (m mockConfig) Validate() error { return nil } + +func TestGetFullName(t *testing.T) { + tests := []struct { + parent string + child string + want string + }{ + {"", "child", "child"}, + {"parent", "child", "parent.child"}, + {"a.b", "c", "a.b.c"}, + {"root", "nested.field", "root.nested.field"}, + } + + for _, tt := range tests { + t.Run(tt.parent+"."+tt.child, func(t *testing.T) { + got := getFullName(tt.parent, tt.child) + assert.Equal(t, tt.want, got) + }) + } +}