Commit Graph

10 Commits (bradfitz/expiry_spin)

Author SHA1 Message Date
Josh Bleecher Snyder a5dd0bcb09 util/jsonutil: new package
The cornerstone API is a more memory-efficient Unmarshal.
The savings come from re-using a json.Decoder.

BenchmarkUnmarshal-8      	 4016418	       288 ns/op	       8 B/op	       1 allocs/op
BenchmarkStdUnmarshal-8   	 4189261	       283 ns/op	     184 B/op	       2 allocs/op

It also includes a Bytes type to reduce allocations
when unmarshalling a non-hex-encoded JSON string into a []byte.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
4 years ago
Josh Bleecher Snyder b65eee0745 util/lineread: add docs to Reader
In particular, point out how to stop reading
and detect it on the other side.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
4 years ago
Brad Fitzpatrick c8939ab7c7 util/endian: add Native variable to get the platform's native binary.ByteOrder
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
4 years ago
Brad Fitzpatrick ff50ddf1ee util/racebuild: add package to export a race-is-enabled const 4 years ago
Brad Fitzpatrick 000347d4cf util/endian: add package with const for whether platform is big endian 4 years ago
Josh Bleecher Snyder 9784cae23b util/uniq: add new package
This makes it easy to compact slices that contain duplicate elements
by sorting and then uniqing.

This is an alternative to constructing an intermediate map
and then extracting elements from it. It also provides
more control over equality than using a map key does.

Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
4 years ago
Brad Fitzpatrick bc1751a376 util/pidowner: add missing copyright header 4 years ago
Brad Fitzpatrick b14288f96c util/pidowner: add two missing copyright headers 4 years ago
Brad Fitzpatrick 23f01174ea util/pidowner: new package to map from process ID to its user ID 4 years ago
Brad Fitzpatrick c3c607e78a util/lineread: add little package to read lines from files/Readers 4 years ago