Skip to content
Permalink
Browse files

minor optimization of Grid::loadRegion() and saveRegion()

  • Loading branch information...
gentryx committed Nov 2, 2018
1 parent a797eea commit 6555aac640c331381cc3d8c7c91388a2b5604f11
Showing with 6 additions and 3 deletions.
  1. +6 −3 src/libgeodecomp/storage/grid.h
@@ -352,7 +352,6 @@ class Grid : public GridBase<CELL_TYPE, TOPOLOGY::DIM>
"Does this model not support serialization?");
}

// fixme: for better performance, avoid operator[] in inner loop
void saveRegionImplementation(
std::vector<char> *buffer,
const typename Region<DIM>::StreakIterator& begin,
@@ -371,8 +370,10 @@ class Grid : public GridBase<CELL_TYPE, TOPOLOGY::DIM>

for (typename Region<DIM>::StreakIterator i = begin; i != end; ++i) {
Coord<DIM> c = i->origin;
const CELL_TYPE *cell = &(*this)[c];
for (; c.x() < i->endX; ++c.x()) {
archive & (*this)[c];
archive & *cell;
++cell;
}
}
}
@@ -404,8 +405,10 @@ class Grid : public GridBase<CELL_TYPE, TOPOLOGY::DIM>

for (typename Region<DIM>::StreakIterator i = begin; i != end; ++i) {
Coord<DIM> c = i->origin;
CELL_TYPE *cell = &(*this)[c];
for (; c.x() < i->endX; ++c.x()) {
archive & (*this)[c];
archive & *cell;
++cell;
}
}
}

0 comments on commit 6555aac

Please sign in to comment.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.