Fix -Wrange-loop-analysis.
The new xcode-clang in xcode 12 turns on -Wrange-loop-analysis by default, this CL tries to fix problems caused by this. Bug: webrtc:12134 Change-Id: I77fd9a28486690c11dceceafc4d72f131b081788 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191762 Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Cr-Commit-Position: refs/heads/master@{#32559}
This commit is contained in:
parent
5481784385
commit
85fae2acc5
@ -37,7 +37,7 @@ NSObject *ValueFromStatsMember(const RTCStatsMemberInterface *member) {
|
||||
case RTCStatsMemberInterface::kSequenceBool: {
|
||||
std::vector<bool> sequence = *member->cast_to<RTCStatsMember<std::vector<bool>>>();
|
||||
NSMutableArray *array = [NSMutableArray arrayWithCapacity:sequence.size()];
|
||||
for (const auto &item : sequence) {
|
||||
for (auto item : sequence) {
|
||||
[array addObject:[NSNumber numberWithBool:item]];
|
||||
}
|
||||
return [array copy];
|
||||
|
||||
@ -35,6 +35,20 @@ std::string VectorToString(const std::vector<T>& vector) {
|
||||
return sb.Release();
|
||||
}
|
||||
|
||||
// This overload is required because std::vector<bool> range loops don't
|
||||
// return references but objects, causing -Wrange-loop-analysis diagnostics.
|
||||
std::string VectorToString(const std::vector<bool>& vector) {
|
||||
rtc::StringBuilder sb;
|
||||
sb << "[";
|
||||
const char* separator = "";
|
||||
for (bool element : vector) {
|
||||
sb << separator << rtc::ToString(element);
|
||||
separator = ",";
|
||||
}
|
||||
sb << "]";
|
||||
return sb.Release();
|
||||
}
|
||||
|
||||
// Produces "[\"a\",\"b\",\"c\"]". Works for vectors of both const char* and
|
||||
// std::string element types.
|
||||
template <typename T>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user