int (boolean throwOnEof) { /* * This code uses ugly local variables 'p' and 'l' representing the 'pos' * and 'limit' fields respectively. Using locals rather than fields saves * a few field reads for each whitespace character in a pretty-printed * document, resulting in a 5% speedup. We need to flush 'p' to its field * before any (potentially indirect) call to fillBuffer() and reread both * 'p' and 'l' after any (potentially indirect) call to the same method. */ CharSequence in = this.sourceSequence; int p = position; int l = limit; while (true) { if (p == l) { position = p; break; } int c = in.charAt(p++); if (c == '\n') { //lineNumber++; //lineStart = p; continue; } else if (c == ' ' || c == '\r' || c == '\t') { continue; } if (c == '/') { position = p; if (p == l) { position--; // push back '/' so it's still in the buffer when this method returns boolean charsLoaded = (position + 3) < limit; position++; // consume the '/' again if (!charsLoaded) { return c; } } checkLenient(); char peek = in.charAt(position); switch (peek) { case '*' -> { // skip a /* c-style comment */ position++; if (!skipTo("*/")) { throw createParseError("Unterminated comment"); } p = position + 2; l = limit; } case '/' -> { // skip a // end-of-line comment position++; skipToEndOfLine(); p = position; l = limit; } default -> { return c; } } } else if (c == '#') { position = p; /* * Skip a # hash end-of-line comment. The JSON RFC doesn't * specify this behaviour, but it's required to parse * existing documents. See http://b/2571423. */ checkLenient(); skipToEndOfLine(); p = position; l = limit; } else { position = p; return c; } } if (throwOnEof) { throw createParseError("End of input"); } else { return -1; } }