()
| 273 | | (0x01); // set 1 bit so 0xA0 will be flagged as whitespace |
| 274 | |
| 275 | protected int getCharNWS() throws IOException { |
| 276 | for (; ; ) { |
| 277 | int ch = getChar(); |
| 278 | // getCharNWS is normally called in the context of expecting certain JSON special characters |
| 279 | // such as ":}"]," all of these characters are below 64, including comment chars '/' and '#', |
| 280 | // so we can make this the fast path even w/o checking the range first. We'll only get some |
| 281 | // false-positives while using bare strings (chars "IJMc") |
| 282 | if (((WS_MASK >> ch) & 0x01) == 0) { |
| 283 | return ch; |
| 284 | } else //noinspection StatementWithEmptyBody |
| 285 | if (ch <= ' ') { |
| 286 | // this will only be true if one of the whitespace bits was set |
| 287 | } else if (ch == '/') { |
| 288 | getSlashComment(); |
| 289 | } else if (ch == '#') { |
| 290 | getNewlineComment(); |
| 291 | } else if (!isWhitespace(ch)) { |
| 292 | // we'll only reach here with certain bare strings, errors, or strange whitespace like 0xa0 |
| 293 | return ch; |
| 294 | } |
| 295 | |
| 296 | /* |
| 297 | // getCharNWS is normally called in the context of expecting certain JSON special characters |
| 298 | // such as ":}"]," |
| 299 | // all of these characters are below 64 (including comment chars '/' and '#', so we can make this the fast path |
| 300 | if (ch < 64) { |
| 301 | if (((WS_MASK >> ch) & 0x01) == 0) return ch; |
| 302 | if (ch <= ' ') continue; // whitespace below a normal space |
| 303 | if (ch=='/') { |
| 304 | getSlashComment(); |
| 305 | } else if (ch=='#') { |
| 306 | getNewlineComment(); |
| 307 | } |
| 308 | } else if (!isWhitespace(ch)) { // check for higher whitespace like 0xA0 |
| 309 | return ch; |
| 310 | } |
| 311 | */ |
| 312 | |
| 313 | /* older code |
| 314 | switch (ch) { case ' ' : case '\t' : case '\r' : case '\n' : continue outer; |
| 315 | case '#' : getNewlineComment(); continue outer; case '/' : getSlashComment(); continue |
| 316 | outer; default: return ch; } |
| 317 | */ |
| 318 | } |
| 319 | } |
| 320 | |
| 321 | protected int getCharNWS(int ch) throws IOException { |
| 322 | for (; ; ) { |
no test coverage detected