summaryrefslogtreecommitdiffstats
path: root/vendor/go.uber.org/multierr
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/go.uber.org/multierr')
-rw-r--r--vendor/go.uber.org/multierr/CHANGELOG.md6
-rw-r--r--vendor/go.uber.org/multierr/error.go19
2 files changed, 22 insertions, 3 deletions
diff --git a/vendor/go.uber.org/multierr/CHANGELOG.md b/vendor/go.uber.org/multierr/CHANGELOG.md
index b0814e7c..3ba05276 100644
--- a/vendor/go.uber.org/multierr/CHANGELOG.md
+++ b/vendor/go.uber.org/multierr/CHANGELOG.md
@@ -1,6 +1,12 @@
Releases
========
+v1.8.0 (2022-02-28)
+===================
+
+- `Combine`: perform zero allocations when there are no errors.
+
+
v1.7.0 (2021-05-06)
===================
diff --git a/vendor/go.uber.org/multierr/error.go b/vendor/go.uber.org/multierr/error.go
index faa0a059..f45af149 100644
--- a/vendor/go.uber.org/multierr/error.go
+++ b/vendor/go.uber.org/multierr/error.go
@@ -103,7 +103,7 @@
// if err != nil {
// return err
// }
-// defer multierr.AppendInvoke(err, multierr.Close(conn))
+// defer multierr.AppendInvoke(&err, multierr.Close(conn))
// // ...
// }
//
@@ -372,6 +372,14 @@ func inspect(errors []error) (res inspectResult) {
// fromSlice converts the given list of errors into a single error.
func fromSlice(errors []error) error {
+ // Don't pay to inspect small slices.
+ switch len(errors) {
+ case 0:
+ return nil
+ case 1:
+ return errors[0]
+ }
+
res := inspect(errors)
switch res.Count {
case 0:
@@ -381,8 +389,13 @@ func fromSlice(errors []error) error {
return errors[res.FirstErrorIdx]
case len(errors):
if !res.ContainsMultiError {
- // already flat
- return &multiError{errors: errors}
+ // Error list is flat. Make a copy of it
+ // Otherwise "errors" escapes to the heap
+ // unconditionally for all other cases.
+ // This lets us optimize for the "no errors" case.
+ out := make([]error, len(errors))
+ copy(out, errors)
+ return &multiError{errors: out}
}
}