Bug 1324547 - ensure we're not needlessly copying things in ranged for loop draft
authorSylvestre Ledru <sledru@mozilla.com>
Wed, 21 Dec 2016 18:05:50 +0100
changeset 455902 1b176e05f5366d1b6300b58582bb92adb9cd5068
parent 449685 38470e52b9d3beb7f648d8726d0c731684ddb75c
child 541073 af3c0a28a10158e2dae875b210c36b46e7465a3f
push id40327
push userbmo:sledru@mozilla.com
push dateWed, 04 Jan 2017 14:34:45 +0000
bugs1324547
milestone53.0a1
Bug 1324547 - ensure we're not needlessly copying things in ranged for loop MozReview-Commit-ID: 2NnjjmANem5
dom/plugins/base/nsPluginHost.cpp
media/mtransport/test/ice_unittest.cpp
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -1574,17 +1574,17 @@ nsPluginHost::RegisterFakePlugin(JS::Han
   if (!initDictionary.Init(aCx, aInitDictionary)) {
     return NS_ERROR_FAILURE;
   }
 
   RefPtr<nsFakePluginTag> newTag;
   nsresult rv = nsFakePluginTag::Create(initDictionary, getter_AddRefs(newTag));
   NS_ENSURE_SUCCESS(rv, rv);
 
-  for (auto existingTag : mFakePlugins) {
+  for (const auto& existingTag : mFakePlugins) {
     if (newTag->HandlerURIMatches(existingTag->HandlerURI())) {
       return NS_ERROR_UNEXPECTED;
     }
   }
 
   mFakePlugins.AppendElement(newTag);
   // FIXME-jsplugins do we need to register with the category manager here?  For
   // shumway, for now, probably not.
--- a/media/mtransport/test/ice_unittest.cpp
+++ b/media/mtransport/test/ice_unittest.cpp
@@ -640,17 +640,17 @@ class IceTestPeer : public sigslot::has_
   void SetExpectedRemoteCandidateAddr(const std::string& addr) {
     expected_remote_addr_ = addr;
   }
 
   int GetCandidatesPrivateIpv4Range(size_t stream) {
     std::vector<std::string> candidates = GetCandidates(stream);
 
     int host_net = 0;
-    for (auto c : candidates) {
+    for (const auto& c : candidates) {
       if (c.find("typ host") != std::string::npos) {
         nr_transport_addr addr;
         std::vector<std::string> tokens = split(c, ' ');
         int r = nr_str_port_to_transport_addr(tokens.at(4).c_str(), 0, IPPROTO_UDP, &addr);
         MOZ_ASSERT(!r);
         if (!r && (addr.ip_version == NR_IPV4)) {
           int n = nr_transport_addr_get_private_addr_range(&addr);
           if (n) {
@@ -1604,17 +1604,17 @@ class WebRtcIceGatherTest : public StunT
   }
 
   void DumpCandidates(unsigned int stream) {
     std::vector<std::string> candidates = peer_->GetCandidates(stream);
 
     std::cerr << "Candidates for stream " << stream << "->"
               << candidates.size() << std::endl;
 
-    for (auto c : candidates) {
+    for (const auto& c : candidates) {
       std::cerr << "Candidate: " << c << std::endl;
     }
   }
 
  protected:
   mozilla::UniquePtr<IceTestPeer> peer_;
 };