| 327 | } |
| 328 | |
| 329 | void Signature::ComputeOneRound(size_t next_node_id) { |
| 330 | // Reset the state of the nodes. |
| 331 | int debug_i = 0; |
| 332 | for (auto it = nodes.begin() + next_node_id; it != nodes.end(); ++it) { |
| 333 | auto node = *it; |
| 334 | // The hash at distance 0 never changes, so preserve it. |
| 335 | node->topo_hash_.resize(1); |
| 336 | node->last_hashed_nodes_ = node->node_mask_; |
| 337 | node->hash_is_final_ = false; |
| 338 | if (debug) { |
| 339 | LOG(INFO) << "DEBUG distance=" << 0 << " node " << debug_i++ << " " |
| 340 | << node->name() << " mask=" << std::hex |
| 341 | << node->last_hashed_nodes_; |
| 342 | } |
| 343 | } |
| 344 | |
| 345 | bool stop = false; |
| 346 | // The distance can reach up to nodes.size()+1, to include not only all the |
| 347 | // nodes but also all the redundant paths. |
| 348 | for (int distance = 1; !stop; ++distance) { |
| 349 | for (auto it = nodes.begin() + next_node_id; it != nodes.end(); ++it) { |
| 350 | auto node = *it; |
| 351 | if (node->hash_is_final_) { |
| 352 | continue; |
| 353 | } |
| 354 | node->ComputeTopoHash(distance); |
| 355 | if (node->GetHighTopoHash() <= nodes.size()) { |
| 356 | // Would conflict with one of the reserved values. |
| 357 | node->ReHighTopoHash(); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | // Will be looking for the indications to not stop. |
| 362 | stop = true; |
| 363 | |
| 364 | debug_i = 0; |
| 365 | // The bitmasks get moved after all the hash computations are done. |
| 366 | for (auto it = nodes.begin() + next_node_id; it != nodes.end(); ++it) { |
| 367 | auto node = *it; |
| 368 | if (debug) { |
| 369 | LOG(INFO) << "DEBUG distance=" << distance << " node " << debug_i++ |
| 370 | << " " << node->name() << " oldmask=" << std::hex |
| 371 | << node->last_hashed_nodes_ << " mask=" << std::hex |
| 372 | << node->next_hashed_nodes_; |
| 373 | } |
| 374 | if (node->last_hashed_nodes_ == node->next_hashed_nodes_) { |
| 375 | // Stopped growing, this part of the graph must be fully |
| 376 | // surrounded by nodes that already have the unique ids. |
| 377 | node->hash_is_final_ = true; |
| 378 | } else { |
| 379 | node->last_hashed_nodes_ = node->next_hashed_nodes_; |
| 380 | stop = false; |
| 381 | } |
| 382 | } |
| 383 | } |
| 384 | } |
| 385 | |
| 386 | void Signature::OrderLinks() { |
nothing calls this directly
no test coverage detected