MCPcopy
hub / github.com/fb55/htmlparser2 / fastForwardTo

Method fastForwardTo

src/Tokenizer.ts:380–396  ·  view source on GitHub ↗

* When we wait for one specific character, we can speed things up * by skipping through the buffer until we find it. * @param c Current character code point. * @returns Whether the character was found.

(c: number)

Source from the content-addressed store, hash-verified

378 * @returns Whether the character was found.
379 */
380 private fastForwardTo(c: number): boolean {
381 while (++this.index < this.buffer.length + this.offset) {
382 if (this.buffer.charCodeAt(this.index - this.offset) === c) {
383 return true;
384 }
385 }
386
387 /*
388 * We increment the index at the end of the `parse` loop,
389 * so set it to `buffer.length - 1` here.
390 *
391 * TODO: Refactor `parse` to increment index before calling states.
392 */
393 this.index = this.buffer.length + this.offset - 1;
394
395 return false;
396 }
397
398 /**
399 * Emit a comment token and return to the text state.

Callers 8

stateTextMethod · 0.95
stateInCommentLikeMethod · 0.95
stateInSpecialTagMethod · 0.95
stateInDeclarationMethod · 0.95
stateInSpecialCommentMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected