Bug 1192356 (Part 1) - Take advantage of mozilla::Tie() in SurfaceCache.cpp. r=dholbert
authorSeth Fowler <mark.seth.fowler@gmail.com>
Tue, 11 Aug 2015 23:50:31 -0700
changeset 257411 c84a03221fb38000a1ce261b0d66185b81f4f04a
parent 257410 852cdd10aa76516a9b9d58ebdcc80b17f138605c
child 257412 d4743fcc524c4a761de36ecaa2944d797029b20f
push id14616
push userryanvm@gmail.com
push dateWed, 12 Aug 2015 14:50:53 +0000
treeherderfx-team@295bbb5db86b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1192356
milestone43.0a1
Bug 1192356 (Part 1) - Take advantage of mozilla::Tie() in SurfaceCache.cpp. r=dholbert
image/SurfaceCache.cpp
--- a/image/SurfaceCache.cpp
+++ b/image/SurfaceCache.cpp
@@ -14,16 +14,17 @@
 #include "mozilla/Attributes.h"
 #include "mozilla/DebugOnly.h"
 #include "mozilla/Likely.h"
 #include "mozilla/Move.h"
 #include "mozilla/Mutex.h"
 #include "mozilla/Pair.h"
 #include "mozilla/RefPtr.h"
 #include "mozilla/StaticPtr.h"
+#include "mozilla/Tuple.h"
 #include "nsIMemoryReporter.h"
 #include "gfx2DGlue.h"
 #include "gfxPattern.h"  // Workaround for flaw in bug 921753 part 2.
 #include "gfxPlatform.h"
 #include "gfxPrefs.h"
 #include "imgFrame.h"
 #include "Image.h"
 #include "LookupResult.h"
@@ -656,21 +657,18 @@ public:
     // surface for drawing or there are no matching surfaces left.
     // XXX(seth): This is O(N^2), but N is expected to be very small. If we
     // encounter a performance problem here we can revisit this.
 
     nsRefPtr<CachedSurface> surface;
     DrawableFrameRef ref;
     MatchType matchType = MatchType::NOT_FOUND;
     while (true) {
-      // XXX(seth): This code is begging for std::tie. See bug 1184385.
-      Pair<already_AddRefed<CachedSurface>, MatchType> lookupResult =
+      Tie(surface, matchType) =
         cache->LookupBestMatch(aSurfaceKey, aAlternateFlags);
-      surface = lookupResult.first();
-      matchType = lookupResult.second();
 
       if (!surface) {
         return LookupResult(matchType);  // Lookup in the per-image cache missed.
       }
 
       ref = surface->DrawableRef();
       if (ref) {
         break;