diff options
author | Clifford Wolf <clifford@clifford.at> | 2019-05-23 13:52:48 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-23 13:52:48 +0200 |
commit | ca4694735455512162da1d4a24429ecf350a8abe (patch) | |
tree | c6fedad5bdc78092607216fd95f4d1965ce23080 | |
parent | 5c164d0863078779fd27aefa665b5e6e457ca39b (diff) | |
parent | f0ff31ceea6101cd59ebc6bdff2f253dbbeb06d8 (diff) | |
download | yosys-ca4694735455512162da1d4a24429ecf350a8abe.tar.gz yosys-ca4694735455512162da1d4a24429ecf350a8abe.tar.bz2 yosys-ca4694735455512162da1d4a24429ecf350a8abe.zip |
Merge pull request #1031 from mdaiter/optimizeLookupTableBtor
Optimize numberOfPermutations
-rw-r--r-- | libs/subcircuit/subcircuit.cc | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/libs/subcircuit/subcircuit.cc b/libs/subcircuit/subcircuit.cc index 7c7236833..e8361a67e 100644 --- a/libs/subcircuit/subcircuit.cc +++ b/libs/subcircuit/subcircuit.cc @@ -320,12 +320,10 @@ class SubCircuit::SolverWorker static int numberOfPermutations(const std::vector<std::string> &list) { - int numPermutations = 1; - for (int i = 0; i < int(list.size()); i++) { - assert(numPermutations < maxPermutationsLimit); - numPermutations *= i+1; - } - return numPermutations; + constexpr size_t mappedPermutationsSize = 10; + constexpr int mappedPermutations[mappedPermutationsSize] = {1, 1, 2, 6, 24, 120, 720, 5040, 40320, 362880}; + assert(list.size() < mappedPermutationsSize); + return mappedPermutations[list.size()]; } static void permutateVectorToMap(std::map<std::string, std::string> &map, const std::vector<std::string> &list, int idx) |