Skip to content

Commit 9c9d05a

Browse files
ndunkelb-nasasaikishor
authored andcommitted
switch to copy instead of naive for loop
1 parent 272342a commit 9c9d05a

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

src/mujoco_system_interface.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,18 +1160,10 @@ bool MujocoSystemInterface::set_override_start_positions(const std::string& over
11601160
return false;
11611161
}
11621162

1163-
for (size_t i = 0; i < qpos.size(); i++)
1164-
{
1165-
mj_data_->qpos[i] = qpos[i];
1166-
}
1167-
for (size_t i = 0; i < qvel.size(); i++)
1168-
{
1169-
mj_data_->qvel[i] = qvel[i];
1170-
}
1171-
for (size_t i = 0; i < ctrl.size(); i++)
1172-
{
1173-
mj_data_->ctrl[i] = ctrl[i];
1174-
}
1163+
// copy data from the input information into the mj_data_ object
1164+
std::copy(qpos.begin(), qpos.end(), mj_data_->qpos);
1165+
std::copy(qvel.begin(), qvel.end(), mj_data_->qvel);
1166+
std::copy(ctrl.begin(), ctrl.end(), mj_data_->ctrl);
11751167

11761168
return true;
11771169
}

0 commit comments

Comments
 (0)