go /
text /
7eb4c23133611333b835471ee3b9b1a5f92d6cf0 go.text.transform: added Reset method to Transformer interface.
Reasons to pick explicit Reset instead of optional one:
- Explict reset is about 3-4 times faster.
- More Transformers than I expected (7 of 19 currently in go.text) can use
a Reset method to some extent.
- Simpler code overall compared to an implementation of an optional Reset.
- Makes it easier to change implementations that currently don't need
a Reset method to use one later.
I'm somewhat ambivalent about the NopResetter type, but it does simplify
the code a bit. One notable advantage is that it gives standardized
documentation for the Reset method of types embedding this type.
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews
https://golang.org/cl/144400043
13 files changed