perf(config): optimize getfullname (#5328)

Co-authored-by: qiuwenhao <qiushaotest@qq.com>
This commit is contained in:
Qiu shao
2025-12-10 22:46:26 +08:00
committed by GitHub
parent 7b23f73268
commit 4ff3975c5a
2 changed files with 21 additions and 1 deletions

View File

@@ -368,5 +368,5 @@ func getFullName(parent, child string) string {
return child
}
return strings.Join([]string{parent, child}, ".")
return parent + "." + child
}

View File

@@ -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)
})
}
}