Use Abseil container algorithms in rtc_base/

Bug: None
Change-Id: I4499adaf8e777d570a3bc119ee29727ab7c790a5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/128962
Commit-Queue: Steve Anton <steveanton@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27271}
This commit is contained in:
Steve Anton
2019-03-25 13:48:30 -07:00
committed by Commit Bot
parent 8f4338495d
commit 2acd163448
16 changed files with 76 additions and 93 deletions

View File

@ -620,6 +620,7 @@ rtc_static_library("rtc_numerics") {
":checks", ":checks",
":rtc_base_approved", ":rtc_base_approved",
":safe_compare", ":safe_compare",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]
} }
@ -800,6 +801,7 @@ rtc_static_library("rtc_base") {
"system:file_wrapper", "system:file_wrapper",
"third_party/base64", "third_party/base64",
"third_party/sigslot", "third_party/sigslot",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/strings", "//third_party/abseil-cpp/absl/strings",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
@ -1107,6 +1109,7 @@ rtc_source_set("rtc_base_tests_utils") {
":rtc_base", ":rtc_base",
"../api/units:time_delta", "../api/units:time_delta",
"third_party/sigslot", "third_party/sigslot",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
] ]
} }
@ -1340,6 +1343,7 @@ if (rtc_include_tests) {
":rtc_base_tests_main", ":rtc_base_tests_main",
":rtc_numerics", ":rtc_numerics",
"../test:test_support", "../test:test_support",
"//third_party/abseil-cpp/absl/algorithm:container",
] ]
} }
@ -1414,6 +1418,7 @@ if (rtc_include_tests) {
"../test:test_support", "../test:test_support",
"synchronization:synchronization_unittests", "synchronization:synchronization_unittests",
"third_party/sigslot", "third_party/sigslot",
"//third_party/abseil-cpp/absl/algorithm:container",
"//third_party/abseil-cpp/absl/memory", "//third_party/abseil-cpp/absl/memory",
"//third_party/abseil-cpp/absl/types:optional", "//third_party/abseil-cpp/absl/types:optional",
] ]

View File

@ -10,7 +10,6 @@
#include "rtc_base/file_rotating_stream.h" #include "rtc_base/file_rotating_stream.h"
#include <algorithm>
#include <cstdio> #include <cstdio>
#include <string> #include <string>
#include <utility> #include <utility>
@ -24,6 +23,7 @@
#include <unistd.h> #include <unistd.h>
#endif // WEBRTC_WIN #endif // WEBRTC_WIN
#include "absl/algorithm/container.h"
#include "absl/strings/match.h" #include "absl/strings/match.h"
#include "absl/types/optional.h" #include "absl/types/optional.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
@ -391,8 +391,7 @@ FileRotatingStreamReader::FileRotatingStreamReader(
// Plain sort of the file names would sort by age, i.e., oldest last. Using // Plain sort of the file names would sort by age, i.e., oldest last. Using
// std::greater gives us the desired chronological older, oldest first. // std::greater gives us the desired chronological older, oldest first.
std::sort(file_names_.begin(), file_names_.end(), absl::c_sort(file_names_, std::greater<std::string>());
std::greater<std::string>());
} }
FileRotatingStreamReader::~FileRotatingStreamReader() = default; FileRotatingStreamReader::~FileRotatingStreamReader() = default;

View File

@ -13,9 +13,9 @@
#include <errno.h> #include <errno.h>
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm>
#include <string> #include <string>
#include "absl/algorithm/container.h"
#include "rtc_base/async_socket.h" #include "rtc_base/async_socket.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
@ -198,8 +198,7 @@ void FirewallSocketServer::SetUnbindableIps(
} }
bool FirewallSocketServer::IsBindableIp(const rtc::IPAddress& ip) { bool FirewallSocketServer::IsBindableIp(const rtc::IPAddress& ip) {
return std::find(unbindable_ips_.begin(), unbindable_ips_.end(), ip) == return !absl::c_linear_search(unbindable_ips_, ip);
unbindable_ips_.end();
} }
Socket* FirewallSocketServer::CreateSocket(int family, int type) { Socket* FirewallSocketServer::CreateSocket(int family, int type) {

View File

@ -7,10 +7,10 @@
* in the file PATENTS. All contributing project authors may * in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include <algorithm>
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/algorithm/container.h"
#include "rtc_base/atomic_ops.h" #include "rtc_base/atomic_ops.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
@ -78,8 +78,7 @@ void MessageQueueManager::RemoveInternal(MessageQueue* message_queue) {
// Prevent changes while the list of message queues is processed. // Prevent changes while the list of message queues is processed.
RTC_DCHECK_EQ(processing_, 0); RTC_DCHECK_EQ(processing_, 0);
std::vector<MessageQueue*>::iterator iter; std::vector<MessageQueue*>::iterator iter;
iter = std::find(message_queues_.begin(), message_queues_.end(), iter = absl::c_find(message_queues_, message_queue);
message_queue);
if (iter != message_queues_.end()) { if (iter != message_queues_.end()) {
message_queues_.erase(iter); message_queues_.erase(iter);
} }

View File

@ -31,9 +31,11 @@
#include <stdio.h> #include <stdio.h>
#include <algorithm>
#include <memory> #include <memory>
#include "absl/algorithm/container.h"
#include "absl/strings/match.h"
#include "absl/strings/string_view.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/network_monitor.h" #include "rtc_base/network_monitor.h"
@ -187,14 +189,13 @@ std::string MakeNetworkKey(const std::string& name,
} }
// Test if the network name matches the type<number> pattern, e.g. eth0. The // Test if the network name matches the type<number> pattern, e.g. eth0. The
// matching is case-sensitive. // matching is case-sensitive.
bool MatchTypeNameWithIndexPattern(const std::string& network_name, bool MatchTypeNameWithIndexPattern(absl::string_view network_name,
const std::string& type_name) { absl::string_view type_name) {
if (network_name.find(type_name) != 0) { if (!absl::StartsWith(network_name, type_name)) {
return false; return false;
} }
return std::find_if(network_name.begin() + type_name.size(), return absl::c_none_of(network_name.substr(type_name.size()),
network_name.end(), [](char c) { return !isdigit(c); });
[](char c) { return !isdigit(c); }) == network_name.end();
} }
// A cautious note that this method may not provide an accurate adapter type // A cautious note that this method may not provide an accurate adapter type
@ -319,7 +320,7 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
// with the same key. // with the same key.
std::map<std::string, AddressList> consolidated_address_list; std::map<std::string, AddressList> consolidated_address_list;
NetworkList list(new_networks); NetworkList list(new_networks);
std::sort(list.begin(), list.end(), CompareNetworks); absl::c_sort(list, CompareNetworks);
// First, build a set of network-keys to the ipaddresses. // First, build a set of network-keys to the ipaddresses.
for (Network* network : list) { for (Network* network : list) {
bool might_add_to_merged_list = false; bool might_add_to_merged_list = false;
@ -400,11 +401,10 @@ void NetworkManagerBase::MergeNetworkList(const NetworkList& new_networks,
for (const auto& kv : networks_map_) { for (const auto& kv : networks_map_) {
Network* network = kv.second; Network* network = kv.second;
// If |network| is in the newly generated |networks_|, it is active. // If |network| is in the newly generated |networks_|, it is active.
bool found = std::find(networks_.begin(), networks_.end(), network) != bool found = absl::c_linear_search(networks_, network);
networks_.end();
network->set_active(found); network->set_active(found);
} }
std::sort(networks_.begin(), networks_.end(), SortNetworks); absl::c_sort(networks_, SortNetworks);
// Now network interfaces are sorted, we should set the preference value // Now network interfaces are sorted, we should set the preference value
// for each of the interfaces we are planning to use. // for each of the interfaces we are planning to use.
// Preference order of network interfaces might have changed from previous // Preference order of network interfaces might have changed from previous
@ -459,10 +459,9 @@ Network* NetworkManagerBase::GetNetworkFromAddress(
const rtc::IPAddress& ip) const { const rtc::IPAddress& ip) const {
for (Network* network : networks_) { for (Network* network : networks_) {
const auto& ips = network->GetIPs(); const auto& ips = network->GetIPs();
if (std::find_if(ips.begin(), ips.end(), if (absl::c_any_of(ips, [&](const InterfaceAddress& existing_ip) {
[ip](const InterfaceAddress& existing_ip) {
return ip == static_cast<rtc::IPAddress>(existing_ip); return ip == static_cast<rtc::IPAddress>(existing_ip);
}) != ips.end()) { })) {
return network; return network;
} }
} }
@ -1004,7 +1003,7 @@ bool Network::SetIPs(const std::vector<InterfaceAddress>& ips, bool changed) {
changed = changed || ips.size() != ips_.size(); changed = changed || ips.size() != ips_.size();
if (!changed) { if (!changed) {
for (const InterfaceAddress& ip : ips) { for (const InterfaceAddress& ip : ips) {
if (std::find(ips_.begin(), ips_.end(), ip) == ips_.end()) { if (!absl::c_linear_search(ips_, ip)) {
changed = true; changed = true;
break; break;
} }

View File

@ -24,10 +24,16 @@
#include "rtc_base/ifaddrs_converter.h" #include "rtc_base/ifaddrs_converter.h"
#endif // defined(WEBRTC_POSIX) #endif // defined(WEBRTC_POSIX)
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
#include "test/gmock.h"
#if defined(WEBRTC_WIN) #if defined(WEBRTC_WIN)
#include "rtc_base/logging.h" // For RTC_LOG_GLE #include "rtc_base/logging.h" // For RTC_LOG_GLE
#endif #endif
using ::testing::Contains;
using ::testing::Not;
using ::testing::UnorderedElementsAre;
using ::testing::UnorderedElementsAreArray;
namespace rtc { namespace rtc {
namespace { namespace {
@ -478,12 +484,8 @@ TEST_F(NetworkTest, TestIPv6MergeNetworkList) {
EXPECT_EQ(stats.ipv4_network_count, 0); EXPECT_EQ(stats.ipv4_network_count, 0);
NetworkManager::NetworkList list; NetworkManager::NetworkList list;
manager.GetNetworks(&list); manager.GetNetworks(&list);
EXPECT_EQ(original_list.size(), list.size());
// Verify that the original members are in the merged list. // Verify that the original members are in the merged list.
for (NetworkManager::NetworkList::iterator it = original_list.begin(); EXPECT_THAT(list, UnorderedElementsAreArray(original_list));
it != original_list.end(); ++it) {
EXPECT_NE(list.end(), std::find(list.begin(), list.end(), *it));
}
} }
// Tests that when two network lists that describe the same set of networks are // Tests that when two network lists that describe the same set of networks are
@ -506,18 +508,11 @@ TEST_F(NetworkTest, TestNoChangeMerge) {
EXPECT_FALSE(changed); EXPECT_FALSE(changed);
NetworkManager::NetworkList resulting_list; NetworkManager::NetworkList resulting_list;
manager.GetNetworks(&resulting_list); manager.GetNetworks(&resulting_list);
EXPECT_EQ(original_list.size(), resulting_list.size());
// Verify that the original members are in the merged list. // Verify that the original members are in the merged list.
for (NetworkManager::NetworkList::iterator it = original_list.begin(); EXPECT_THAT(resulting_list, UnorderedElementsAreArray(original_list));
it != original_list.end(); ++it) {
EXPECT_NE(resulting_list.end(),
std::find(resulting_list.begin(), resulting_list.end(), *it));
}
// Doublecheck that the new networks aren't in the list. // Doublecheck that the new networks aren't in the list.
for (NetworkManager::NetworkList::iterator it = second_list.begin(); for (const Network* network : second_list) {
it != second_list.end(); ++it) { EXPECT_THAT(resulting_list, Not(Contains(network)));
EXPECT_EQ(resulting_list.end(),
std::find(resulting_list.begin(), resulting_list.end(), *it));
} }
} }
@ -554,7 +549,7 @@ TEST_F(NetworkTest, MergeWithChangedIP) {
manager.GetNetworks(&list); manager.GetNetworks(&list);
EXPECT_EQ(original_list.size(), list.size()); EXPECT_EQ(original_list.size(), list.size());
// Make sure the original network is still in the merged list. // Make sure the original network is still in the merged list.
EXPECT_NE(list.end(), std::find(list.begin(), list.end(), network_to_change)); EXPECT_THAT(list, Contains(network_to_change));
EXPECT_EQ(changed_ip, network_to_change->GetIPs().at(0)); EXPECT_EQ(changed_ip, network_to_change->GetIPs().at(0));
} }
@ -598,18 +593,12 @@ TEST_F(NetworkTest, TestMultipleIPMergeNetworkList) {
// This should be the same network object as before. // This should be the same network object as before.
EXPECT_EQ((*it), original_list[2]); EXPECT_EQ((*it), original_list[2]);
// But with two addresses now. // But with two addresses now.
EXPECT_EQ(2U, (*it)->GetIPs().size()); EXPECT_THAT((*it)->GetIPs(),
EXPECT_NE((*it)->GetIPs().end(), UnorderedElementsAre(InterfaceAddress(check_ip),
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
InterfaceAddress(check_ip)));
EXPECT_NE((*it)->GetIPs().end(),
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
InterfaceAddress(ip))); InterfaceAddress(ip)));
} else { } else {
// Check the IP didn't get added anywhere it wasn't supposed to. // Check the IP didn't get added anywhere it wasn't supposed to.
EXPECT_EQ((*it)->GetIPs().end(), EXPECT_THAT((*it)->GetIPs(), Not(Contains(InterfaceAddress(ip))));
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
InterfaceAddress(ip)));
} }
} }
} }
@ -650,9 +639,7 @@ TEST_F(NetworkTest, TestMultiplePublicNetworksOnOneInterfaceMerge) {
EXPECT_EQ(ip, (*it)->GetIPs().at(0)); EXPECT_EQ(ip, (*it)->GetIPs().at(0));
} else { } else {
// Check the IP didn't get added anywhere it wasn't supposed to. // Check the IP didn't get added anywhere it wasn't supposed to.
EXPECT_EQ((*it)->GetIPs().end(), EXPECT_THAT((*it)->GetIPs(), Not(Contains(InterfaceAddress(ip))));
std::find((*it)->GetIPs().begin(), (*it)->GetIPs().end(),
InterfaceAddress(ip)));
} }
} }
} }

View File

@ -9,11 +9,12 @@
*/ */
#include <stdlib.h> #include <stdlib.h>
#include <algorithm> #include <array>
#include <climits> #include <climits>
#include <cstdint> #include <cstdint>
#include <random> #include <random>
#include "absl/algorithm/container.h"
#include "rtc_base/constructor_magic.h" #include "rtc_base/constructor_magic.h"
#include "rtc_base/numerics/percentile_filter.h" #include "rtc_base/numerics/percentile_filter.h"
#include "test/gtest.h" #include "test/gtest.h"
@ -110,14 +111,13 @@ TEST_P(PercentileFilterTest, DuplicateElements) {
} }
TEST_P(PercentileFilterTest, InsertAndEraseTenValuesInRandomOrder) { TEST_P(PercentileFilterTest, InsertAndEraseTenValuesInRandomOrder) {
int64_t zero_to_nine[10] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::array<int64_t, 10> zero_to_nine = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
// The percentile value of the ten values above. // The percentile value of the ten values above.
const int64_t expected_value = static_cast<int64_t>(GetParam() * 9); const int64_t expected_value = static_cast<int64_t>(GetParam() * 9);
// Insert two sets of |zero_to_nine| in random order. // Insert two sets of |zero_to_nine| in random order.
for (int i = 0; i < 2; ++i) { for (int i = 0; i < 2; ++i) {
std::shuffle(zero_to_nine, zero_to_nine + 10, absl::c_shuffle(zero_to_nine, std::mt19937(std::random_device()()));
std::mt19937(std::random_device()()));
for (int64_t value : zero_to_nine) for (int64_t value : zero_to_nine)
filter_.Insert(value); filter_.Insert(value);
// After inserting a full set of |zero_to_nine|, the percentile should // After inserting a full set of |zero_to_nine|, the percentile should
@ -127,13 +127,11 @@ TEST_P(PercentileFilterTest, InsertAndEraseTenValuesInRandomOrder) {
// Insert and erase sets of |zero_to_nine| in random order a few times. // Insert and erase sets of |zero_to_nine| in random order a few times.
for (int i = 0; i < 3; ++i) { for (int i = 0; i < 3; ++i) {
std::shuffle(zero_to_nine, zero_to_nine + 10, absl::c_shuffle(zero_to_nine, std::mt19937(std::random_device()()));
std::mt19937(std::random_device()()));
for (int64_t value : zero_to_nine) for (int64_t value : zero_to_nine)
filter_.Erase(value); filter_.Erase(value);
EXPECT_EQ(expected_value, filter_.GetPercentileValue()); EXPECT_EQ(expected_value, filter_.GetPercentileValue());
std::shuffle(zero_to_nine, zero_to_nine + 10, absl::c_shuffle(zero_to_nine, std::mt19937(std::random_device()()));
std::mt19937(std::random_device()()));
for (int64_t value : zero_to_nine) for (int64_t value : zero_to_nine)
filter_.Insert(value); filter_.Insert(value);
EXPECT_EQ(expected_value, filter_.GetPercentileValue()); EXPECT_EQ(expected_value, filter_.GetPercentileValue());

View File

@ -10,9 +10,10 @@
#include "rtc_base/numerics/samples_stats_counter.h" #include "rtc_base/numerics/samples_stats_counter.h"
#include <algorithm>
#include <cmath> #include <cmath>
#include "absl/algorithm/container.h"
namespace webrtc { namespace webrtc {
SamplesStatsCounter::SamplesStatsCounter() = default; SamplesStatsCounter::SamplesStatsCounter() = default;
@ -42,7 +43,7 @@ double SamplesStatsCounter::GetPercentile(double percentile) {
RTC_CHECK_GE(percentile, 0); RTC_CHECK_GE(percentile, 0);
RTC_CHECK_LE(percentile, 1); RTC_CHECK_LE(percentile, 1);
if (!sorted_) { if (!sorted_) {
std::sort(samples_.begin(), samples_.end()); absl::c_sort(samples_);
sorted_ = true; sorted_ = true;
} }
const double raw_rank = percentile * (samples_.size() - 1); const double raw_rank = percentile * (samples_.size() - 1);

View File

@ -11,10 +11,10 @@
#include "rtc_base/numerics/samples_stats_counter.h" #include "rtc_base/numerics/samples_stats_counter.h"
#include <math.h> #include <math.h>
#include <algorithm>
#include <random> #include <random>
#include <vector> #include <vector>
#include "absl/algorithm/container.h"
#include "test/gtest.h" #include "test/gtest.h"
namespace webrtc { namespace webrtc {
@ -25,7 +25,7 @@ SamplesStatsCounter CreateStatsFilledWithIntsFrom1ToN(int n) {
for (int i = 1; i <= n; i++) { for (int i = 1; i <= n; i++) {
data.push_back(i); data.push_back(i);
} }
std::shuffle(data.begin(), data.end(), std::mt19937(std::random_device()())); absl::c_shuffle(data, std::mt19937(std::random_device()()));
SamplesStatsCounter stats; SamplesStatsCounter stats;
for (double v : data) { for (double v : data) {

View File

@ -10,7 +10,6 @@
#include "rtc_base/openssl_key_derivation_hkdf.h" #include "rtc_base/openssl_key_derivation_hkdf.h"
#include <algorithm>
#include <utility> #include <utility>
#include <openssl/ossl_typ.h> #include <openssl/ossl_typ.h>
@ -24,6 +23,7 @@
#include <openssl/err.h> #include <openssl/err.h>
#include <openssl/sha.h> #include <openssl/sha.h>
#include "absl/algorithm/container.h"
#include "rtc_base/buffer.h" #include "rtc_base/buffer.h"
#include "rtc_base/openssl.h" #include "rtc_base/openssl.h"
@ -91,7 +91,7 @@ absl::optional<ZeroOnFreeBuffer<uint8_t>> OpenSSLKeyDerivationHKDF::DeriveKey(
rtc::Buffer salt_buffer; rtc::Buffer salt_buffer;
if (salt.data() == nullptr || salt.size() == 0) { if (salt.data() == nullptr || salt.size() == 0) {
salt_buffer.SetSize(SHA256_DIGEST_LENGTH); salt_buffer.SetSize(SHA256_DIGEST_LENGTH);
std::fill(salt_buffer.begin(), salt_buffer.end(), 0); absl::c_fill(salt_buffer, 0);
salt = salt_buffer; salt = salt_buffer;
} }
// This buffer will erase itself on release. // This buffer will erase itself on release.

View File

@ -11,7 +11,6 @@
#include "rtc_base/proxy_server.h" #include "rtc_base/proxy_server.h"
#include <stddef.h> #include <stddef.h>
#include <algorithm>
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"

View File

@ -10,10 +10,10 @@
#include "rtc_base/ssl_certificate.h" #include "rtc_base/ssl_certificate.h"
#include <algorithm>
#include <string> #include <string>
#include <utility> #include <utility>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/openssl_certificate.h" #include "rtc_base/openssl_certificate.h"
@ -89,8 +89,8 @@ SSLCertChain::~SSLCertChain() = default;
std::unique_ptr<SSLCertChain> SSLCertChain::Clone() const { std::unique_ptr<SSLCertChain> SSLCertChain::Clone() const {
std::vector<std::unique_ptr<SSLCertificate>> new_certs(certs_.size()); std::vector<std::unique_ptr<SSLCertificate>> new_certs(certs_.size());
std::transform( absl::c_transform(
certs_.begin(), certs_.end(), new_certs.begin(), certs_, new_certs.begin(),
[](const std::unique_ptr<SSLCertificate>& cert) [](const std::unique_ptr<SSLCertificate>& cert)
-> std::unique_ptr<SSLCertificate> { return cert->Clone(); }); -> std::unique_ptr<SSLCertificate> { return cert->Clone(); });
return absl::make_unique<SSLCertChain>(std::move(new_certs)); return absl::make_unique<SSLCertChain>(std::move(new_certs));

View File

@ -11,10 +11,10 @@
#include "rtc_base/ssl_fingerprint.h" #include "rtc_base/ssl_fingerprint.h"
#include <ctype.h> #include <ctype.h>
#include <algorithm>
#include <cstdint> #include <cstdint>
#include <string> #include <string>
#include "absl/algorithm/container.h"
#include "absl/memory/memory.h" #include "absl/memory/memory.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
#include "rtc_base/message_digest.h" #include "rtc_base/message_digest.h"
@ -113,8 +113,7 @@ bool SSLFingerprint::operator==(const SSLFingerprint& other) const {
std::string SSLFingerprint::GetRfc4572Fingerprint() const { std::string SSLFingerprint::GetRfc4572Fingerprint() const {
std::string fingerprint = std::string fingerprint =
rtc::hex_encode_with_delimiter(digest.data<char>(), digest.size(), ':'); rtc::hex_encode_with_delimiter(digest.data<char>(), digest.size(), ':');
std::transform(fingerprint.begin(), fingerprint.end(), fingerprint.begin(), absl::c_transform(fingerprint, fingerprint.begin(), ::toupper);
::toupper);
return fingerprint; return fingerprint;
} }

View File

@ -13,10 +13,10 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <algorithm>
#include <list> #include <list>
#include <memory> #include <memory>
#include "absl/algorithm/container.h"
#include "rtc_base/async_packet_socket.h" #include "rtc_base/async_packet_socket.h"
#include "rtc_base/async_socket.h" #include "rtc_base/async_socket.h"
#include "rtc_base/async_tcp_socket.h" #include "rtc_base/async_tcp_socket.h"
@ -55,8 +55,7 @@ class TestEchoServer : public sigslot::has_slots<> {
socket->Send(buf, size, options); socket->Send(buf, size, options);
} }
void OnClose(AsyncPacketSocket* socket, int err) { void OnClose(AsyncPacketSocket* socket, int err) {
ClientList::iterator it = ClientList::iterator it = absl::c_find(client_sockets_, socket);
std::find(client_sockets_.begin(), client_sockets_.end(), socket);
client_sockets_.erase(it); client_sockets_.erase(it);
Thread::Current()->Dispose(socket); Thread::Current()->Dispose(socket);
} }

View File

@ -8,10 +8,10 @@
* be found in the AUTHORS file in the root of the source tree. * be found in the AUTHORS file in the root of the source tree.
*/ */
#include "algorithm" #include <string>
#include "string" #include <vector>
#include "vector"
#include "absl/algorithm/container.h"
#include "api/array_view.h" #include "api/array_view.h"
#include "rtc_base/gunit.h" #include "rtc_base/gunit.h"
#include "rtc_base/helpers.h" #include "rtc_base/helpers.h"
@ -69,11 +69,11 @@ TYPED_TEST(UniqueIdGeneratorTest, KnownElementsAreNotGenerated) {
values.push_back(generator2()); values.push_back(generator2());
} }
EXPECT_THAT(values, ::testing::SizeIs(num_elements)); EXPECT_THAT(values, ::testing::SizeIs(num_elements));
std::sort(values.begin(), values.end()); absl::c_sort(values);
std::sort(known_values.begin(), known_values.end()); absl::c_sort(known_values);
std::vector<typename Generator::value_type> intersection; std::vector<typename Generator::value_type> intersection;
std::set_intersection(values.begin(), values.end(), known_values.begin(), absl::c_set_intersection(values, known_values,
known_values.end(), std::back_inserter(intersection)); std::back_inserter(intersection));
EXPECT_THAT(intersection, IsEmpty()); EXPECT_THAT(intersection, IsEmpty());
} }
@ -100,11 +100,11 @@ TYPED_TEST(UniqueIdGeneratorTest, AddedElementsAreNotGenerated) {
values.push_back(generator2()); values.push_back(generator2());
} }
EXPECT_THAT(values, ::testing::SizeIs(num_elements)); EXPECT_THAT(values, ::testing::SizeIs(num_elements));
std::sort(values.begin(), values.end()); absl::c_sort(values);
std::sort(known_values.begin(), known_values.end()); absl::c_sort(known_values);
std::vector<typename Generator::value_type> intersection; std::vector<typename Generator::value_type> intersection;
std::set_intersection(values.begin(), values.end(), known_values.begin(), absl::c_set_intersection(values, known_values,
known_values.end(), std::back_inserter(intersection)); std::back_inserter(intersection));
EXPECT_THAT(intersection, IsEmpty()); EXPECT_THAT(intersection, IsEmpty());
} }

View File

@ -13,11 +13,11 @@
#include <errno.h> #include <errno.h>
#include <math.h> #include <math.h>
#include <algorithm>
#include <map> #include <map>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "absl/algorithm/container.h"
#include "rtc_base/checks.h" #include "rtc_base/checks.h"
#include "rtc_base/fake_clock.h" #include "rtc_base/fake_clock.h"
#include "rtc_base/logging.h" #include "rtc_base/logging.h"
@ -1108,7 +1108,7 @@ VirtualSocketServer::Function* VirtualSocketServer::Invert(Function* f) {
for (Function::size_type i = 0; i < f->size(); ++i) for (Function::size_type i = 0; i < f->size(); ++i)
std::swap((*f)[i].first, (*f)[i].second); std::swap((*f)[i].first, (*f)[i].second);
std::sort(f->begin(), f->end(), FunctionDomainCmp()); absl::c_sort(*f, FunctionDomainCmp());
return f; return f;
} }
@ -1129,8 +1129,7 @@ VirtualSocketServer::Function* VirtualSocketServer::Resample(Function* f,
} }
double VirtualSocketServer::Evaluate(Function* f, double x) { double VirtualSocketServer::Evaluate(Function* f, double x) {
Function::iterator iter = Function::iterator iter = absl::c_lower_bound(*f, x, FunctionDomainCmp());
std::lower_bound(f->begin(), f->end(), x, FunctionDomainCmp());
if (iter == f->begin()) { if (iter == f->begin()) {
return (*f)[0].second; return (*f)[0].second;
} else if (iter == f->end()) { } else if (iter == f->end()) {