| 339 | } |
| 340 | |
| 341 | Y_FORCE_INLINE bool Advance( |
| 342 | const char*& dataPos, |
| 343 | const char* const dataEnd, |
| 344 | char label |
| 345 | ) { |
| 346 | if (dataPos == nullptr) { |
| 347 | return false; |
| 348 | } |
| 349 | |
| 350 | while (dataPos < dataEnd) { |
| 351 | size_t offsetLength, offset; |
| 352 | const char* startPos = dataPos; |
| 353 | char flags = *(dataPos++); |
| 354 | char symbol = *(dataPos++); |
| 355 | dataPos += sizeof(NCompactTrie::TSuffixLink); |
| 356 | |
| 357 | // Left branch |
| 358 | offsetLength = NCompactTrie::LeftOffsetLen(flags); |
| 359 | if ((unsigned char)label < (unsigned char)symbol) { |
| 360 | offset = NCompactTrie::UnpackOffset(dataPos, offsetLength); |
| 361 | if (!offset) |
| 362 | break; |
| 363 | |
| 364 | dataPos = startPos + offset; |
| 365 | continue; |
| 366 | } |
| 367 | |
| 368 | dataPos += offsetLength; |
| 369 | |
| 370 | // Right branch |
| 371 | offsetLength = NCompactTrie::RightOffsetLen(flags); |
| 372 | if ((unsigned char)label > (unsigned char)symbol) { |
| 373 | offset = NCompactTrie::UnpackOffset(dataPos, offsetLength); |
| 374 | if (!offset) |
| 375 | break; |
| 376 | |
| 377 | dataPos = startPos + offset; |
| 378 | continue; |
| 379 | } |
| 380 | |
| 381 | dataPos = startPos; |
| 382 | return true; |
| 383 | } |
| 384 | |
| 385 | // if we got here, we're past the dataend - bail out ASAP |
| 386 | dataPos = nullptr; |
| 387 | return false; |
| 388 | } |
| 389 | |
| 390 | } // anonymous |
| 391 |
no test coverage detected