Skip to content

Commit

Permalink
Remove useless code
Browse files Browse the repository at this point in the history
Signed-off-by: Tianrui Zheng <[email protected]>
  • Loading branch information
Tianrui Zheng committed Dec 13, 2024
1 parent 2a6390a commit f5dce65
Showing 1 changed file with 0 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -175,39 +175,6 @@ private void extractMemoryLayout() {
}
}

// Getting the correct relation to extract is tricky.
// In the case of redefinition, we care about the one defined last.
// If there is no redefinition, we simply return the original one.
private Relation getRelationWithName(String name) {
// First check if the original definition is asked.
if (name.endsWith("#0")) {
String originalName = name.substring(0, name.lastIndexOf("#"));
return wmm.getRelation(originalName);
}

int maxId = -1;
for (Relation r : wmm.getRelations()) {
int defIndex = -1;
for (String n : r.getNames()) {
if (n.startsWith(name + "#")) {
defIndex = tryParseInt(n).orElse(-1);
if (defIndex > -1) { break; }
}
}
maxId = Math.max(maxId, defIndex);
}
return maxId != -1 ? wmm.getRelation(name + "#" + maxId) : wmm.getRelation(name);
}

private Optional<Integer> tryParseInt(String s) {
try {
int n = Integer.parseInt(s.substring(s.lastIndexOf("#") + 1));
return Optional.of(n);
} catch (NumberFormatException e) {
return Optional.empty();
}
}

private void extractRelations() {
Set<Relation> relsToExtract = new HashSet<>(wmm.getRelations());
for (Relation r : relsToExtract) { createModel(r); }
Expand Down

0 comments on commit f5dce65

Please sign in to comment.