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
This will be used in the upcoming cases package.
Also expanded the tests and fixed some code to be a bit more robust in
case a Transformer returns ErrShortDst while making progress.
LGTM=nigeltao
R=nigeltao
CC=golang-codereviews, r
https://golang.org/cl/101630043
runes from the input. This corresponds to ICU's Remove transform.
For example, to remove accents from characters one could use RemoveFunc
as follows:
nonspacingMark := func(r rune) bool {
return unicode.Is(unicode.Mn, r)
}
transform.Chain(norm.NFD, transform.RemoveFunc(nonspacingMark), norm.NFC)
(Once norm.Form implements Transformer; guess what will be my next CL.)
R=r
CC=golang-dev, nigeltao
https://golang.org/cl/23220043
This CL only provides the Reader type; Writer will be in a follow-up.
R=mpvl, r, mpvl
CC=andybalholm, golang-dev, rogpeppe
https://golang.org/cl/10538043