diff options
Diffstat (limited to 'internal')
-rw-r--r-- | internal/fastio/allwriter.go | 3 | ||||
-rw-r--r-- | internal/jsonparse/parse.go | 20 |
2 files changed, 11 insertions, 12 deletions
diff --git a/internal/fastio/allwriter.go b/internal/fastio/allwriter.go index c587531..071d709 100644 --- a/internal/fastio/allwriter.go +++ b/internal/fastio/allwriter.go @@ -139,6 +139,9 @@ func (w writerYYNWrapper) WriteString(s string) (int, error) { return WriteStrin // the io.Writer already has any of the other write methods, then its // native version of those methods are used. func NewAllWriter(inner io.Writer) AllWriter { + if inner == io.Discard { + return Discard + } switch inner := inner.(type) { // 3 Y bits case AllWriter: // YYY: diff --git a/internal/jsonparse/parse.go b/internal/jsonparse/parse.go index 2f5c1ab..d867cbc 100644 --- a/internal/jsonparse/parse.go +++ b/internal/jsonparse/parse.go @@ -324,8 +324,7 @@ type Parser struct { } type barrier struct { - closed bool - stack []RuneType + stack []RuneType } func (par *Parser) init() { @@ -387,7 +386,7 @@ func (par *Parser) Reset() { } } -// PushReadBarrier causes the parser to expect EOF once the end of the +// PushReadBarrier causes the parser to emit EOF once the end of the // element that is started by the current top-of-stack is reached, // until this is un-done with PopBarrier. It essentially turns the // parser in to a sub-parser. @@ -425,14 +424,13 @@ func (par *Parser) PushReadBarrier() { } // Actually push. par.barriers = append(par.barriers, barrier{ - closed: par.closed, - stack: par.stack[:len(par.stack)-1], + stack: par.stack[:len(par.stack)-1], }) par.stack = []RuneType{curState} } -// PushWriteBarrier causes the parser to expect EOF once the end of -// the about-to-start element is reached, until this is un-done with +// PushWriteBarrier causes the parser to emit EOF once the end of the +// about-to-start element is reached, until this is un-done with // PopBarrier. It essentially turns the parser in to a sub-parser. // // PushWriteBarrier may only be called at the places where an element @@ -453,15 +451,13 @@ func (par *Parser) PushWriteBarrier() { case runeTypeAny: par.popState() par.barriers = append(par.barriers, barrier{ - closed: par.closed, - stack: par.stack, + stack: par.stack, }) par.stack = []RuneType{runeTypeAny} case RuneTypeArrayBeg: par.replaceState(RuneTypeArrayComma) par.barriers = append(par.barriers, barrier{ - closed: par.closed, - stack: par.stack, + stack: par.stack, }) par.stack = []RuneType{runeTypeAny} default: @@ -476,7 +472,7 @@ func (par *Parser) PopBarrier() { } barrier := par.barriers[len(par.barriers)-1] par.barriers = par.barriers[:len(par.barriers)-1] - par.closed = barrier.closed + par.closed = false par.stack = append(barrier.stack, par.stack...) } |