mirror of
https://github.com/zeromicro/go-zero.git
synced 2026-05-13 18:00:00 +08:00
perf: pre-allocate all known length arrays to avoid re-scaling (#5029)
Co-authored-by: Kevin Wan <wanjunfeng@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a2b98dbcf7
commit
130e1ba963
@@ -67,11 +67,11 @@ func enumsValueFromOptions(options []string) []any {
|
||||
}
|
||||
for _, option := range options {
|
||||
if strings.HasPrefix(option, enumFlag) {
|
||||
var resp = make([]any, 0)
|
||||
val := option[8:]
|
||||
fields := util.FieldsAndTrimSpace(val, func(r rune) bool {
|
||||
return r == '|'
|
||||
})
|
||||
var resp = make([]any, 0, len(fields))
|
||||
for _, field := range fields {
|
||||
resp = append(resp, field)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user