mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-04 18:00:08 +00:00
apierrors: optimize ToAggregate() for zero-length lists
This commit is contained in:
parent
57fdd167e4
commit
091724a6d8
@ -239,6 +239,9 @@ func NewErrorTypeMatcher(t ErrorType) utilerrors.Matcher {
|
|||||||
|
|
||||||
// ToAggregate converts the ErrorList into an errors.Aggregate.
|
// ToAggregate converts the ErrorList into an errors.Aggregate.
|
||||||
func (list ErrorList) ToAggregate() utilerrors.Aggregate {
|
func (list ErrorList) ToAggregate() utilerrors.Aggregate {
|
||||||
|
if len(list) == 0 {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
errs := make([]error, 0, len(list))
|
errs := make([]error, 0, len(list))
|
||||||
errorMsgs := sets.NewString()
|
errorMsgs := sets.NewString()
|
||||||
for _, err := range list {
|
for _, err := range list {
|
||||||
|
Loading…
Reference in New Issue
Block a user