Commit ac27678f authored by Harvey Yang's avatar Harvey Yang Committed by Commit Bot

accelerometer: Iterate samples

As the samples' channels should be ordered (accel_x, accel_y, accel_z),
using ++it should reduce the complexity slightly compared with using
find for each channel.

BUG=b:172208566, b:172414227
TEST=builds, unit tests, and run on octopus

Change-Id: Ibfcb385f71aec5c202a50940c04954393be0817a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519348
Commit-Queue: Cheng-Hao Yang <chenghaoyang@chromium.org>
Reviewed-by: default avatarXiaoqian Dai <xdai@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828055}
parent 2735f040
......@@ -57,9 +57,15 @@ void AccelerometerSamplesObserver::OnSampleUpdated(
return;
}
auto it = sample.begin();
std::vector<float> output_sample;
for (size_t axes = 0; axes < kNumberOfAxes; ++axes) {
auto it = sample.find(channel_indices_[axes]);
if (axes != 0)
++it;
if (it == sample.end() || it->first != channel_indices_[axes])
it = sample.find(channel_indices_[axes]);
if (it == sample.end()) {
LOG(ERROR) << "Missing channel: " << kAccelerometerChannels[axes]
<< " in sample";
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment