| 376 | } |
| 377 | |
| 378 | void ByteMapBuilder::Merge() { |
| 379 | for (std::vector<std::pair<int, int>>::const_iterator it = ranges_.begin(); |
| 380 | it != ranges_.end(); |
| 381 | ++it) { |
| 382 | int lo = it->first-1; |
| 383 | int hi = it->second; |
| 384 | |
| 385 | if (0 <= lo && !splits_.Test(lo)) { |
| 386 | splits_.Set(lo); |
| 387 | int next = splits_.FindNextSetBit(lo+1); |
| 388 | colors_[lo] = colors_[next]; |
| 389 | } |
| 390 | if (!splits_.Test(hi)) { |
| 391 | splits_.Set(hi); |
| 392 | int next = splits_.FindNextSetBit(hi+1); |
| 393 | colors_[hi] = colors_[next]; |
| 394 | } |
| 395 | |
| 396 | int c = lo+1; |
| 397 | while (c < 256) { |
| 398 | int next = splits_.FindNextSetBit(c); |
| 399 | colors_[next] = Recolor(colors_[next]); |
| 400 | if (next == hi) |
| 401 | break; |
| 402 | c = next+1; |
| 403 | } |
| 404 | } |
| 405 | colormap_.clear(); |
| 406 | ranges_.clear(); |
| 407 | } |
| 408 | |
| 409 | void ByteMapBuilder::Build(uint8_t* bytemap, int* bytemap_range) { |
| 410 | // Assign byte classes numbered from 0. |
no test coverage detected