Skip to content

Commit 7a1ff8a

Browse files
increment curRow at the end of the loop
1 parent f83a9f6 commit 7a1ff8a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

OpenSim/Common/DelimFileAdapter.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -418,11 +418,10 @@ DelimFileAdapter<T>::extendRead(const std::string& fileName) const {
418418
auto row = nextLine();
419419
while (!row.empty()) {
420420
++line_num;
421-
++curRow;
422421

423422
// Double capacity if we reach the end of the containers.
424423
// This is necessary until Simbody issue #401 is addressed.
425-
if (curRow > curCapacity) {
424+
if (curRow+1 > curCapacity) {
426425
curCapacity *= 2;
427426
timeVec.reserve(curCapacity);
428427
matrix.resizeKeep(curCapacity, ncol);
@@ -441,9 +440,10 @@ DelimFileAdapter<T>::extendRead(const std::string& fileName) const {
441440
column_labels.size(),
442441
static_cast<size_t>(row_vector.size()));
443442

444-
matrix.updRow(curRow-1) = std::move(row_vector);
443+
matrix.updRow(curRow) = std::move(row_vector);
445444

446445
row = nextLine();
446+
++curRow;
447447
}
448448

449449
// Resize the matrix down to the correct number of rows.

0 commit comments

Comments
 (0)