Skip to content

Commit

Permalink
use do while
Browse files Browse the repository at this point in the history
  • Loading branch information
reza-j committed Mar 6, 2024
1 parent 3d187b1 commit 15db4b5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/Dialect/QUIR/Transforms/BreakReset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,15 @@ void BreakResetPass::finishCircuit(mlir::quir::CircuitOp circOp,
}

std::string BreakResetPass::getMangledName() {
auto mangledName = "reset_circuit_" + std::to_string(circuitCounter);
// TODO: replace this with an O(1) algorithm
while (circuitsSymbolMap.contains(mangledName)) {
std::string baseName = "reset_circuit_";
std::string mangledName;

// TODO: replace this with an O(1) algorithm to obtain mangled name
do {
mangledName = baseName + std::to_string(circuitCounter);
circuitCounter += 1;
mangledName = "reset_circuit_" + std::to_string(circuitCounter);
}
} while (circuitsSymbolMap.contains(mangledName));

return mangledName;
}

Expand Down

0 comments on commit 15db4b5

Please sign in to comment.