Skip to content

Commit c39926e

Browse files
authored
[MLIR][Presburger] Fix style violations in ff80414 (NFC) (#76720)
Use preincrement not postincrement; use `Identifier::getIds` not `getVarKindOffset`
1 parent 4f71068 commit c39926e

File tree

1 file changed

+8
-13
lines changed

1 file changed

+8
-13
lines changed

mlir/lib/Analysis/Presburger/PresburgerSpace.cpp

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -299,30 +299,25 @@ void PresburgerSpace::mergeAndAlignSymbols(PresburgerSpace &other) {
299299
"Both spaces need to have identifers to merge & align");
300300

301301
// First merge & align identifiers into `other` from `this`.
302-
unsigned kindBeginOffset = other.getVarKindOffset(VarKind::Symbol);
303302
unsigned i = 0;
304-
for (const Identifier *identifier =
305-
identifiers.begin() + getVarKindOffset(VarKind::Symbol);
306-
identifier != identifiers.begin() + getVarKindEnd(VarKind::Symbol);
307-
identifier++) {
303+
for (const Identifier identifier : getIds(VarKind::Symbol)) {
308304
// If the identifier exists in `other`, then align it; otherwise insert it
309305
// assuming it is a new identifier. Search in `other` starting at position
310306
// `i` since the left of `i` is aligned.
311-
auto *findEnd =
312-
other.identifiers.begin() + other.getVarKindEnd(VarKind::Symbol);
313-
auto *itr = std::find(other.identifiers.begin() + kindBeginOffset + i,
314-
findEnd, *identifier);
307+
auto *findBegin = other.getIds(VarKind::Symbol).begin() + i;
308+
auto *findEnd = other.getIds(VarKind::Symbol).end();
309+
auto *itr = std::find(findBegin, findEnd, identifier);
315310
if (itr != findEnd) {
316-
std::iter_swap(other.identifiers.begin() + kindBeginOffset + i, itr);
311+
std::swap(findBegin, itr);
317312
} else {
318313
other.insertVar(VarKind::Symbol, i);
319-
other.getId(VarKind::Symbol, i) = *identifier;
314+
other.getId(VarKind::Symbol, i) = identifier;
320315
}
321-
i++;
316+
++i;
322317
}
323318

324319
// Finally add identifiers that are in `other`, but not in `this` to `this`.
325-
for (unsigned e = other.getNumVarKind(VarKind::Symbol); i < e; i++) {
320+
for (unsigned e = other.getNumVarKind(VarKind::Symbol); i < e; ++i) {
326321
insertVar(VarKind::Symbol, i);
327322
getId(VarKind::Symbol, i) = other.getId(VarKind::Symbol, i);
328323
}

0 commit comments

Comments
 (0)