]> Cypherpunks repositories - gostls13.git/commit
os/user: cache the result of user.Current
authorSameer Ajmani <sameer@golang.org>
Mon, 6 Feb 2017 18:21:57 +0000 (13:21 -0500)
committerSameer Ajmani <sameer@golang.org>
Mon, 6 Feb 2017 18:49:52 +0000 (18:49 +0000)
commit2ca5d105b00353d3f3aa4da023e405b0550117d0
tree46d243d496488476f599392d1495116bcbc2bc3b
parentfd37b8ccf2262bb3f0a608f7545f78a72e8d661f
os/user: cache the result of user.Current

This has a notable impact on systems with very large passwd files.

Before:
BenchmarkCurrent-12        30000      42546 ns/op

After:
BenchmarkCurrent-12     20000000         77.5 ns/op

Saved in perf dashboard:
https://perf.golang.org/search?q=upload:20170206.1

Fixes #11625

Change-Id: Iebc9bf122cc64a4cab24ac06843c7b2bc450ded9
Reviewed-on: https://go-review.googlesource.com/36391
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/user/lookup.go
src/os/user/user_test.go