Skip to content

Commit

Permalink
optimize Grid::symmetrize()
Browse files Browse the repository at this point in the history
by avoiding vector<bool>.

I also tried tiling (inner loop iterating 8x8x8 cubes),
but it's less efficient.
  • Loading branch information
wojdyr committed Nov 10, 2023
1 parent e01d383 commit c238fcd
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions include/gemmi/grid.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,7 @@ struct Grid : GridBase<T> {
if (ops.empty())
return;
std::vector<size_t> mates(ops.size(), 0);
std::vector<bool> visited(data.size(), false);
std::vector<signed char> visited(data.size(), 0); // faster than vector<bool>
size_t idx = 0;
for (int w = 0; w != nw; ++w)
for (int v = 0; v != nv; ++v)
Expand All @@ -735,10 +735,10 @@ struct Grid : GridBase<T> {
value = func(value, data[k]);
}
data[idx] = value;
visited[idx] = true;
visited[idx] = 1;
for (size_t k : mates) {
data[k] = value;
visited[k] = true;
visited[k] = 1;
}
}
assert(idx == data.size());
Expand Down

0 comments on commit c238fcd

Please sign in to comment.