rate: double reserveN perf by 2x

This commit increase the speed of reserveN by 2x by removing the defer
to unlock.

NOTE: I did an audit of the code between Lock and Unlock and did not see
anything that can panic causing the Unlock to averted.

benchmark             old ns/op     new ns/op     delta
BenchmarkAllowN-4     290           143           -50.69%

benchmark             old allocs     new allocs     delta
BenchmarkAllowN-4     0              0              +0.00%

benchmark             old bytes     new bytes     delta
BenchmarkAllowN-4     0             0             +0.00%

Change-Id: I01c23f4998f5451ea8efedd02e744fb5a74eae0d
Reviewed-on: https://go-review.googlesource.com/29379
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2 files changed
tree: 91147e879b04987e4ca9f21f5c4c22d52450b707
  1. rate/
  2. AUTHORS
  3. CONTRIBUTING.md
  4. CONTRIBUTORS
  5. LICENSE
  6. PATENTS
  7. README