MCPcopy Create free account
hub / github.com/antchfx/xmlquery / updateLineNumber

Method updateLineNumber

parse.go:137–165  ·  view source on GitHub ↗

updateLineNumber scans only new cached data for newlines to update current line position

()

Source from the content-addressed store, hash-verified

135
136// updateLineNumber scans only new cached data for newlines to update current line position
137func (p *parser) updateLineNumber() {
138 if p.lineStarts == nil {
139 return
140 }
141 offset := int(p.decoder.InputOffset())
142 for i := p.currentLine; i < len(p.lineStarts); i++ {
143 if offset > p.lineStarts[i] && p.lineStarts[i] >= p.lastProcessedPos {
144 p.currentLine = i + 1
145 break
146 }
147 if offset <= p.lineStarts[i] {
148 break
149 }
150 }
151 p.lastProcessedPos = offset
152 /*
153 cached := p.reader.CacheWithLimit(-1) // Get all cached data
154
155 // Only process data we haven't seen before
156 for i := p.lastProcessedPos; i < len(cached); i++ {
157 if cached[i] == '\n' {
158 p.currentLine++
159 }
160 }
161
162 // Update our position to avoid reprocessing this data
163 p.lastProcessedPos = len(cached)
164 */
165}
166
167func (p *parser) parse() (*Node, error) {
168 p.once.Do(func() {

Callers 1

parseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected