Skip to content

Commit 160e764

Browse files
committed
add a comment explaining the new lines
1 parent f47c78b commit 160e764

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Source/Particles/ParticleBoundaryBuffer.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,8 @@ void ParticleBoundaryBuffer::gatherParticlesFromDomainBoundaries (MultiParticleC
462462
auto np_to_add = amrex::get<0>(reduce_data.value());
463463
auto new_np = dst_index + np_to_add;
464464
amrex::Long capacity = ptile_buffer.capacity() / species_buffer.superParticleSize();
465+
// reserve space to avoid many small resize operations for performance reasons
466+
// the resize below will not shrink the capacity
465467
if (new_np > capacity) { ptile_buffer.reserve(2*new_np); }
466468
ptile_buffer.resize(new_np);
467469
}
@@ -570,6 +572,8 @@ void ParticleBoundaryBuffer::gatherParticlesFromEmbeddedBoundaries (
570572
auto np_to_add = amrex::get<0>(reduce_data.value());
571573
auto new_np = dst_index + np_to_add;
572574
amrex::Long capacity = ptile_buffer.capacity() / species_buffer.superParticleSize();
575+
// reserve space to avoid many small resize operations for performance reasons
576+
// the resize below will not shrink the capacity
573577
if (new_np > capacity) { ptile_buffer.reserve(2*new_np); }
574578
ptile_buffer.resize(new_np);
575579
}

0 commit comments

Comments
 (0)