diff options
author | Wim <wim@42.be> | 2023-01-28 22:57:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-28 22:57:53 +0100 |
commit | 880586bac42817ffcfea5d9f746f503fa29915b8 (patch) | |
tree | a89374cba6f88975f12316ec8d1b8aa1d4c6ba79 /vendor/go.uber.org/multierr | |
parent | eac2a8c8dc831f946970d327e2a80b26b0684255 (diff) | |
download | matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.gz matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.tar.bz2 matterbridge-msglm-880586bac42817ffcfea5d9f746f503fa29915b8.zip |
Update dependencies (#1951)
Diffstat (limited to 'vendor/go.uber.org/multierr')
-rw-r--r-- | vendor/go.uber.org/multierr/CHANGELOG.md | 6 | ||||
-rw-r--r-- | vendor/go.uber.org/multierr/error.go | 19 |
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} } } |