| 424 | } |
| 425 | |
| 426 | int ByteMapBuilder::Recolor(int oldcolor) { |
| 427 | // Yes, this is a linear search. There can be at most 256 |
| 428 | // colors and there will typically be far fewer than that. |
| 429 | // Also, we need to consider keys *and* values in order to |
| 430 | // avoid recoloring a given range more than once per batch. |
| 431 | std::vector<std::pair<int, int>>::const_iterator it = |
| 432 | std::find_if(colormap_.begin(), colormap_.end(), |
| 433 | [=](const std::pair<int, int>& kv) -> bool { |
| 434 | return kv.first == oldcolor || kv.second == oldcolor; |
| 435 | }); |
| 436 | if (it != colormap_.end()) |
| 437 | return it->second; |
| 438 | int newcolor = nextcolor_; |
| 439 | nextcolor_++; |
| 440 | colormap_.emplace_back(oldcolor, newcolor); |
| 441 | return newcolor; |
| 442 | } |
| 443 | |
| 444 | void Prog::ComputeByteMap() { |
| 445 | // Fill in bytemap with byte classes for the program. |
nothing calls this directly
no test coverage detected