-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UUIDs: implement encoding methods, enhance testing and improve perfor…
…mance This changeset implements these interfaces found in the encoding package: - MarshalBinary() (data []byte, err error) - UnmarshalBinary(data []byte) error - AppendBinary(b []byte) ([]byte, error) - MarshalText() (text []byte, err error) - UnmarshalText(text []byte) error - AppendText(b []byte) ([]byte, error) ParseUUID and uuid.String are now implemented in terms of these new methods. UnmarshalText and AppendText use algorithms inspired by the hex package. Also the UUID.String method has been optimized to avoid allocations by using unsafe.String. Finally the new UnmarshalText supports 128, 32 and 16 bit uuids. Additional tests were added to verify the new methods and some existing methods missing coverage. Benchmark results (using benchstat, 10 runs each): - `ParseUUID`: ~71.04% faster (p=0.000, n=10) - `UUID.String()`: ~81.26% faster (p=0.000, n=10) - `UUID.String()`: Memory allocations reduced by 100% (48 B/op to 0 B/op)
- Loading branch information
1 parent
680584e
commit dd26313
Showing
2 changed files
with
509 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.