Skip to content

Commit fcbdc29

Browse files
committed
Placed the loop body of simplifyFormulas into another separate function
1 parent 118750e commit fcbdc29

File tree

2 files changed

+31
-17
lines changed

2 files changed

+31
-17
lines changed

src/api/MainSolver.cc

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -141,23 +141,10 @@ bool MainSolver::tryAddTermNameFor(PTRef fla, std::string const & name) {
141141
sstat MainSolver::simplifyFormulas() {
142142
status = s_Undef;
143143
for (std::size_t i = firstNotPreprocessedFrame; i < frames.frameCount(); ++i) {
144-
auto & frame = frames[i];
145-
FrameId const frameId = frame.getId();
146-
PreprocessingContext context{.frameCount = i, .perPartition = trackPartitions()};
147-
preprocessor.prepareForProcessingFrame(i);
148-
firstNotPreprocessedFrame = i + 1;
149-
150-
if (not context.perPartition) {
151-
PTRef frameFormula = preprocessFormulasDefault(frame.formulas, context);
152-
status = giveToSolver(frameFormula, frameId);
153-
} else {
154-
vec<PTRef> processedFormulas = preprocessFormulasPerPartition(frame.formulas, context);
155-
for (PTRef fla : processedFormulas) {
156-
status = giveToSolver(fla, frameId);
157-
if (status == s_False) { break; }
158-
}
159-
}
160-
if (status == s_False) { break; }
144+
assert(status != s_False);
145+
if (tryPreprocessFormulasOfFrame(i)) { continue; }
146+
assert(status == s_False);
147+
break;
161148
}
162149

163150
if (status == s_False) {
@@ -168,6 +155,31 @@ sstat MainSolver::simplifyFormulas() {
168155
return status;
169156
}
170157

158+
bool MainSolver::tryPreprocessFormulasOfFrame(std::size_t i) {
159+
auto & frame = frames[i];
160+
FrameId const frameId = frame.getId();
161+
PreprocessingContext context{.frameCount = i, .perPartition = trackPartitions()};
162+
preprocessor.prepareForProcessingFrame(i);
163+
firstNotPreprocessedFrame = i + 1;
164+
165+
assert(status != s_False);
166+
167+
if (not context.perPartition) {
168+
PTRef frameFormula = preprocessFormulasDefault(frame.formulas, context);
169+
status = giveToSolver(frameFormula, frameId);
170+
return status != s_False;
171+
}
172+
173+
vec<PTRef> processedFormulas = preprocessFormulasPerPartition(frame.formulas, context);
174+
for (PTRef fla : processedFormulas) {
175+
status = giveToSolver(fla, frameId);
176+
if (status == s_False) { return false; }
177+
}
178+
179+
assert(status != s_False);
180+
return true;
181+
}
182+
171183
PTRef MainSolver::preprocessFormulasDefault(vec<PTRef> const & frameFormulas, PreprocessingContext const & context) {
172184
assert(not context.perPartition);
173185

src/api/MainSolver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ class MainSolver {
291291

292292
inline bool trackPartitions() const;
293293

294+
virtual bool tryPreprocessFormulasOfFrame(std::size_t);
295+
294296
virtual PTRef preprocessFormulasDefault(vec<PTRef> const & frameFormulas, PreprocessingContext const &);
295297
virtual vec<PTRef> preprocessFormulasPerPartition(vec<PTRef> const & frameFormulas, PreprocessingContext const &);
296298

0 commit comments

Comments
 (0)