mirror of
https://github.com/YosysHQ/yosys
synced 2025-04-07 01:54:10 +00:00
Optimize numberOfPermutations
This commit is contained in:
parent
cb24d23b6d
commit
f0ff31ceea
|
@ -320,12 +320,10 @@ class SubCircuit::SolverWorker
|
||||||
|
|
||||||
static int numberOfPermutations(const std::vector<std::string> &list)
|
static int numberOfPermutations(const std::vector<std::string> &list)
|
||||||
{
|
{
|
||||||
int numPermutations = 1;
|
constexpr size_t mappedPermutationsSize = 10;
|
||||||
for (int i = 0; i < int(list.size()); i++) {
|
constexpr int mappedPermutations[mappedPermutationsSize] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880};
|
||||||
assert(numPermutations < maxPermutationsLimit);
|
assert(list.size() < mappedPermutationsSize);
|
||||||
numPermutations *= i+1;
|
return mappedPermutations[list.size()];
|
||||||
}
|
|
||||||
return numPermutations;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void permutateVectorToMap(std::map<std::string, std::string> &map, const std::vector<std::string> &list, int idx)
|
static void permutateVectorToMap(std::map<std::string, std::string> &map, const std::vector<std::string> &list, int idx)
|
||||||
|
|
Loading…
Reference in a new issue