MCPcopy Create free account
hub / github.com/segmentio/encoding / Reset

Method Reset

json/token.go:83–102  ·  view source on GitHub ↗

Reset erases the state of t and re-initializes it with the json input from b.

(b []byte)

Source from the content-addressed store, hash-verified

81
82// Reset erases the state of t and re-initializes it with the json input from b.
83func (t *Tokenizer) Reset(b []byte) {
84 if t.stack != nil {
85 releaseStack(t.stack)
86 }
87 // This code is similar to:
88 //
89 // *t = Tokenizer{json: b}
90 //
91 // However, it does not compile down to an invocation of duff-copy.
92 t.Delim = 0
93 t.Value = nil
94 t.Err = nil
95 t.Depth = 0
96 t.Index = 0
97 t.IsKey = false
98 t.isKey = false
99 t.json = b
100 t.stack = nil
101 t.decoder = decoder{flags: internalParseFlags(b)}
102}
103
104// Next returns a new tokenizer pointing at the next token, or the zero-value of
105// Tokenizer if the end of the json input has been reached.

Callers 8

BenchmarkTokenizerFunction · 0.95
NextMethod · 0.95
TestCompactFunction · 0.45
TestIndentFunction · 0.45
TestIndentBigFunction · 0.45
TestSetTrustRawMessageFunction · 0.45
TestSetAppendNewlineFunction · 0.45
EncodeMethod · 0.45

Calls 2

releaseStackFunction · 0.85
internalParseFlagsFunction · 0.85

Tested by 6

BenchmarkTokenizerFunction · 0.76
TestCompactFunction · 0.36
TestIndentFunction · 0.36
TestIndentBigFunction · 0.36
TestSetTrustRawMessageFunction · 0.36
TestSetAppendNewlineFunction · 0.36