From af43932c20d5b59cdffca45406754dbccbb46dfa Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 3 Apr 2024 11:50:36 +0200 Subject: errors: return early for Is(nil, ...) If err is nil it wouldn't match any given target error except for nil, so we can return early to speed up cases where Is is used without a preceding err != nil check. Change-Id: Ib33cff50453fe070f06871ce8074694c81ab787b Reviewed-on: https://go-review.googlesource.com/c/go/+/576015 Reviewed-by: Dmitri Shuralyov LUCI-TryBot-Result: Go LUCI Auto-Submit: Tobias Klauser Reviewed-by: Ian Lance Taylor --- src/errors/wrap_test.go | 1 + 1 file changed, 1 insertion(+) (limited to 'src/errors/wrap_test.go') diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go index 0a7bc5d16a..58ed95fd9a 100644 --- a/src/errors/wrap_test.go +++ b/src/errors/wrap_test.go @@ -30,6 +30,7 @@ func TestIs(t *testing.T) { match bool }{ {nil, nil, true}, + {nil, err1, false}, {err1, nil, false}, {err1, err1, true}, {erra, err1, true}, -- cgit v1.3