diff options
author | Frediano Ziglio <freddy77@gmail.com> | 2020-04-28 10:53:04 +0100 |
---|---|---|
committer | Frediano Ziglio <freddy77@gmail.com> | 2020-05-06 13:36:49 +0100 |
commit | 21cbdc8ae418212b6f24fc08db09f1b5c1dc1498 (patch) | |
tree | bb4a398263e1d3899a65a8912d656f7bd429281e /src | |
parent | 6a80b4b050e8e19412368890aef4daf93be818a6 (diff) |
Make grow_changed_tiles loop a bit more readable
It was not clear that a lot of tests were here just to handle
borders.
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/scan.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -210,7 +210,7 @@ static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED, } for (j = 0; j < NUM_HORIZONTAL_TILES; j++) { - int grow = 0; + bool grow; if (tiles_changed[i][j]) { continue; @@ -219,15 +219,14 @@ static void grow_changed_tiles(scanner_t *scanner G_GNUC_UNUSED, /* You get good optimizations from having multiple rows, so be more aggressive in growing the first and last tile; just require a neighbor be set */ - if (j == 0 && tiles_changed[i][1]) - grow++; - else if (j == NUM_HORIZONTAL_TILES - 1 && tiles_changed[i][j - 1]) - grow++; + if (j == 0) + grow = tiles_changed[i][1]; + else if (j == NUM_HORIZONTAL_TILES - 1) + grow = tiles_changed[i][j - 1]; /* Otherwise, require that growing 'fills' a gap */ - else if (j > 0 && j < (NUM_HORIZONTAL_TILES - 1) && - tiles_changed[i][j - 1] && tiles_changed[i][j + 1]) - grow++; + else + grow = tiles_changed[i][j - 1] && tiles_changed[i][j + 1]; if (grow) { tiles_changed[i][j] = true; |