Skip to content

Commit

Permalink
AutoMapping: Avoid overhead of modulo when they're 1
Browse files Browse the repository at this point in the history
20% faster overal, on a test case with big maps.
  • Loading branch information
bjorn committed Apr 8, 2022
1 parent 562edb6 commit 4c0e82d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/tiled/automapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1119,9 +1119,9 @@ void AutoMapper::matchRule(const Rule &rule,
}

forEachPointInRegion(ruleMatchRegion, [&] (int x, int y) {
if ((x + rule.options.offsetX) % rule.options.modX != 0)
if (rule.options.modX != 1 && (x + rule.options.offsetX) % rule.options.modX != 0)
return;
if ((y + rule.options.offsetY) % rule.options.modY != 0)
if (rule.options.modX != 1 && (y + rule.options.offsetY) % rule.options.modY != 0)
return;
if (rule.options.skipChance != 0.0 && randomDouble() < rule.options.skipChance)
return;
Expand Down

0 comments on commit 4c0e82d

Please sign in to comment.