3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-04-13 04:28:18 +00:00

Merge pull request #1031 from mdaiter/optimizeLookupTableBtor

Optimize numberOfPermutations
This commit is contained in:
Clifford Wolf 2019-05-23 13:52:48 +02:00 committed by GitHub
commit ca46947354
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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)