// Copyright 2013 The Go Authors. All rights reserved.// Use of this source code is governed by a BSD-style// license that can be found in the LICENSE file.package normimport ()// Reset implements the Reset method of the transform.Transformer interface.func (Form) () {}// Transform implements the Transform method of the transform.Transformer// interface. It may need to write segments of up to MaxSegmentSize at once.// Users should either catch ErrShortDst and allow dst to grow or have dst be at// least of size MaxTransformChunkSize to be guaranteed of progress.func ( Form) (, []byte, bool) (, int, error) {// Cap the maximum number of src bytes to check. := := if := len(); < len() { = transform.ErrShortDst = false = [:] } , := formTable[].quickSpan(inputBytes(), 0, len(), ) := copy(, [:])if ! { , , = .transform([:], [:], )return + , + , }if == nil && < len() && ! { = transform.ErrShortSrc }return , , }func ( *reorderBuffer) bool {// Write out (must fully fit in dst, or else it is an ErrShortDst).iflen(.out) < .nrune*utf8.UTFMax {returnfalse } .out = .out[.flushCopy(.out):]returntrue}varerrs = []error{nil, transform.ErrShortDst, transform.ErrShortSrc}// transform implements the transform.Transformer interface. It is only called// when quickSpan does not pass for a given string.func ( Form) (, []byte, bool) (, int, error) {// TODO: get rid of reorderBuffer. See CL 23460044. := reorderBuffer{} .init(, )for {// Load segment into reorder buffer. .setFlusher([:], flushTransform) := decomposeSegment(&, , )if < 0 {return , , errs[-] } = len() - len(.out) = // Next quickSpan. = .nsrc := if := + len() - ; < { = transform.ErrShortDst = = false } , := .f.quickSpan(.src, , , ) := copy([:], .src.bytes[:]) += += if {if == nil && < .nsrc && ! { = transform.ErrShortSrc }return , , } }}
The pages are generated with Goldsv0.6.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds.