commit cc6701c3292d87dfc97613e917181256eac65a74
parent a8c988d81e49513de74767a583a7e44c3916c705
Author: Dan Baker <dbaker@mozilla.com>
Date: Thu, 23 Oct 2025 16:24:19 -0600
Bug 1995393 - Vendor libwebrtc from e75260273c
Upstream commit: https://webrtc.googlesource.com/src/+/e75260273c2aba193e7ccb1b1f7a704a92dd5d6e
Replace erase-remove idiom with std::erase and std::erase_if (3)
Bug: webrtc:438403372
Change-Id: I08982640d626afd3dfb8bfd8fea363f8e2efa837
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/404584
Reviewed-by: Jonas Oreland <jonaso@webrtc.org>
Commit-Queue: Björn Terelius <terelius@webrtc.org>
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#45355}
Diffstat:
6 files changed, 25 insertions(+), 44 deletions(-)
diff --git a/third_party/libwebrtc/README.mozilla.last-vendor b/third_party/libwebrtc/README.mozilla.last-vendor
@@ -1,4 +1,4 @@
# ./mach python dom/media/webrtc/third_party_build/vendor-libwebrtc.py --from-local /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc --commit mozpatches libwebrtc
-libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T22:21:51.099381+00:00.
+libwebrtc updated from /Users/danielbaker/elm/.moz-fast-forward/moz-libwebrtc commit mozpatches on 2025-10-23T22:24:06.151082+00:00.
# base of lastest vendoring
-b1105f6cdc
+e75260273c
diff --git a/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc b/third_party/libwebrtc/p2p/base/p2p_transport_channel.cc
@@ -1391,15 +1391,13 @@ void P2PTransportChannel::FinishAddingRemoteCandidate(
void P2PTransportChannel::RemoveRemoteCandidate(
const Candidate& cand_to_remove) {
RTC_DCHECK_RUN_ON(network_thread_);
- auto iter =
- std::remove_if(remote_candidates_.begin(), remote_candidates_.end(),
- [cand_to_remove](const Candidate& candidate) {
- return cand_to_remove.MatchesForRemoval(candidate);
- });
- if (iter != remote_candidates_.end()) {
+ size_t num_erased = std::erase_if(
+ remote_candidates_, [cand_to_remove](const Candidate& candidate) {
+ return cand_to_remove.MatchesForRemoval(candidate);
+ });
+ if (num_erased > 0) {
RTC_LOG(LS_VERBOSE) << "Removed remote candidate "
<< cand_to_remove.ToSensitiveString();
- remote_candidates_.erase(iter, remote_candidates_.end());
}
}
diff --git a/third_party/libwebrtc/p2p/base/stun_dictionary.cc b/third_party/libwebrtc/p2p/base/stun_dictionary.cc
@@ -278,10 +278,8 @@ void StunDictionaryWriter::Delete(int key) {
}
// remove any pending updates.
- pending_.erase(
- std::remove_if(pending_.begin(), pending_.end(),
- [key](const auto& p) { return p.second->type() == key; }),
- pending_.end());
+ std::erase_if(pending_,
+ [key](const auto& p) { return p.second->type() == key; });
// Create tombstone.
auto tombstone = std::make_unique<StunByteStringAttribute>(key);
@@ -304,10 +302,8 @@ void StunDictionaryWriter::Set(std::unique_ptr<StunAttribute> attr) {
}
int key = attr->type();
// remove any pending updates.
- pending_.erase(
- std::remove_if(pending_.begin(), pending_.end(),
- [key](const auto& p) { return p.second->type() == key; }),
- pending_.end());
+ std::erase_if(pending_,
+ [key](const auto& p) { return p.second->type() == key; });
// remove any existing key.
tombstones_.erase(key);
diff --git a/third_party/libwebrtc/p2p/client/basic_port_allocator.cc b/third_party/libwebrtc/p2p/client/basic_port_allocator.cc
@@ -420,15 +420,11 @@ std::vector<const Network*> BasicPortAllocatorSession::GetFailedNetworks() {
}
}
- networks.erase(
- std::remove_if(networks.begin(), networks.end(),
- [networks_with_connection](const Network* network) {
- // If a network does not have any connection, it is
- // considered failed.
- return networks_with_connection.find(network->name()) !=
- networks_with_connection.end();
- }),
- networks.end());
+ std::erase_if(networks, [networks_with_connection](const Network* network) {
+ // If a network does not have any connection, it is
+ // considered failed.
+ return networks_with_connection.contains(network->name());
+ });
return networks;
}
diff --git a/third_party/libwebrtc/p2p/client/basic_port_allocator_unittest.cc b/third_party/libwebrtc/p2p/client/basic_port_allocator_unittest.cc
@@ -449,17 +449,12 @@ class BasicPortAllocatorTestBase : public ::testing::Test,
void OnCandidatesRemoved(PortAllocatorSession* session,
const std::vector<Candidate>& removed_candidates) {
- auto new_end = std::remove_if(
- candidates_.begin(), candidates_.end(),
- [removed_candidates](Candidate& candidate) {
- for (const Candidate& removed_candidate : removed_candidates) {
- if (candidate.MatchesForRemoval(removed_candidate)) {
- return true;
- }
- }
- return false;
- });
- candidates_.erase(new_end, candidates_.end());
+ std::erase_if(candidates_, [removed_candidates](Candidate& candidate) {
+ return absl::c_any_of(
+ removed_candidates, [&candidate](const Candidate& removed_candidate) {
+ return candidate.MatchesForRemoval(removed_candidate);
+ });
+ });
}
bool HasRelayAddress(const ProtocolAddress& proto_addr) {
diff --git a/third_party/libwebrtc/p2p/test/fake_ice_transport.h b/third_party/libwebrtc/p2p/test/fake_ice_transport.h
@@ -11,7 +11,6 @@
#ifndef P2P_TEST_FAKE_ICE_TRANSPORT_H_
#define P2P_TEST_FAKE_ICE_TRANSPORT_H_
-#include <algorithm>
#include <cstddef>
#include <cstdint>
#include <map>
@@ -290,15 +289,12 @@ class FakeIceTransport : public IceTransportInternal {
}
void RemoveRemoteCandidate(const Candidate& candidate) override {
RTC_DCHECK_RUN_ON(network_thread_);
- auto it = std::remove_if(
- remote_candidates_.begin(), remote_candidates_.end(),
+ size_t num_erased = std::erase_if(
+ remote_candidates_,
[&](const Candidate& c) { return candidate.MatchesForRemoval(c); });
- if (it == remote_candidates_.end()) {
+ if (num_erased == 0) {
RTC_LOG(LS_INFO) << "Trying to remove a candidate which doesn't exist.";
- return;
}
-
- remote_candidates_.erase(it);
}
void RemoveAllRemoteCandidates() override {