From 303f7d7b6e5a8c3cf4e18a5e9cd052dc9584ea0a Mon Sep 17 00:00:00 2001 From: liu yang Date: Wed, 30 Mar 2022 20:55:02 +0800 Subject: [PATCH] move a calculation out of the loop --- chain.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/chain.go b/chain.go index 01f0e5d..16e5659 100644 --- a/chain.go +++ b/chain.go @@ -47,8 +47,9 @@ func (c Chain) Then(h http.Handler) http.Handler { h = http.DefaultServeMux } + l := len(c.constructors) for i := range c.constructors { - h = c.constructors[len(c.constructors)-1-i](h) + h = c.constructors[l-1-i](h) } return h