Optional: Use nullopt and implicit construction in /modules/audio_processing

Changes places where we explicitly construct an Optional to instead use
nullopt or the requisite value type only.

This CL was uploaded by git cl split.

R=henrik.lundin@webrtc.org

Bug: None
Change-Id: I733a83f702fe11884d229a1713cfac952727bde8
Reviewed-on: https://webrtc-review.googlesource.com/23601
Commit-Queue: Oskar Sundbom <ossu@webrtc.org>
Reviewed-by: Henrik Lundin <henrik.lundin@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20786}
This commit is contained in:
Oskar Sundbom
2017-11-17 14:34:48 +01:00
committed by Commit Bot
parent 28dfeb7f24
commit aa8b67da9d
27 changed files with 124 additions and 147 deletions

View File

@ -65,10 +65,10 @@ rtc::Optional<Point> GetDirectionIfLinear(
const Point pair_direction =
PairDirection(array_geometry[i - 1], array_geometry[i]);
if (!AreParallel(first_pair_direction, pair_direction)) {
return rtc::Optional<Point>();
return rtc::nullopt;
}
}
return rtc::Optional<Point>(first_pair_direction);
return first_pair_direction;
}
rtc::Optional<Point> GetNormalIfPlanar(
@ -86,30 +86,30 @@ rtc::Optional<Point> GetNormalIfPlanar(
}
}
if (is_linear) {
return rtc::Optional<Point>();
return rtc::nullopt;
}
const Point normal_direction =
CrossProduct(first_pair_direction, pair_direction);
for (; i < array_geometry.size(); ++i) {
pair_direction = PairDirection(array_geometry[i - 1], array_geometry[i]);
if (!ArePerpendicular(normal_direction, pair_direction)) {
return rtc::Optional<Point>();
return rtc::nullopt;
}
}
return rtc::Optional<Point>(normal_direction);
return normal_direction;
}
rtc::Optional<Point> GetArrayNormalIfExists(
const std::vector<Point>& array_geometry) {
const rtc::Optional<Point> direction = GetDirectionIfLinear(array_geometry);
if (direction) {
return rtc::Optional<Point>(Point(direction->y(), -direction->x(), 0.f));
return Point(direction->y(), -direction->x(), 0.f);
}
const rtc::Optional<Point> normal = GetNormalIfPlanar(array_geometry);
if (normal && normal->z() < kMaxDotProduct) {
return normal;
}
return rtc::Optional<Point>();
return rtc::nullopt;
}
Point AzimuthToPoint(float azimuth) {