summaryrefslogtreecommitdiff
path: root/vendor/codeberg.org/gruf/go-errors/v2
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/codeberg.org/gruf/go-errors/v2')
-rw-r--r--vendor/codeberg.org/gruf/go-errors/v2/standard.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/vendor/codeberg.org/gruf/go-errors/v2/standard.go b/vendor/codeberg.org/gruf/go-errors/v2/standard.go
index 225d9e0c1..2a4671153 100644
--- a/vendor/codeberg.org/gruf/go-errors/v2/standard.go
+++ b/vendor/codeberg.org/gruf/go-errors/v2/standard.go
@@ -18,14 +18,21 @@ import (
func Is(err error, targets ...error) bool {
var flags bitutil.Flags64
+ // Flags only has 64 bit slots
if len(targets) > 64 {
panic("too many targets")
}
- // Determine if each of targets are comparable
+ // Check if error is nil so we can catch
+ // the fast-case where a target is nil
+ isNil := (err == nil)
+
for i := 0; i < len(targets); {
- // Drop nil errors
+ // Drop nil targets
if targets[i] == nil {
+ if isNil /* match! */ {
+ return true
+ }
targets = append(targets[:i], targets[i+1:]...)
continue
}