Bug 1044658 - 6/6 - expand TestWeakPtr - r=froydnj
authorBenoit Jacob <bjacob@mozilla.com>
Wed, 30 Jul 2014 15:52:06 -0400
changeset 218568 f26c915b1dcceda0ecd4fa1a1f3568cddd3693f3
parent 218567 8a7cbe9ed925429432adad630a9a138c9649a88d
child 218569 621963c110239e77f03cf22ca5f158d362b709b3
push id3979
push userraliiev@mozilla.com
push dateMon, 13 Oct 2014 16:35:44 +0000
treeherdermozilla-beta@30f2cc610691 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfroydnj
bugs1044658
milestone34.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1044658 - 6/6 - expand TestWeakPtr - r=froydnj
dom/canvas/WebGLFramebufferAttachable.cpp
dom/canvas/WebGLFramebufferAttachable.h
--- a/dom/canvas/WebGLFramebufferAttachable.cpp
+++ b/dom/canvas/WebGLFramebufferAttachable.cpp
@@ -6,59 +6,43 @@
 #include "WebGLContext.h"
 #include "WebGLFramebufferAttachable.h"
 #include "WebGLFramebuffer.h"
 #include "WebGLRenderbuffer.h"
 #include "WebGLTexture.h"
 
 using namespace mozilla;
 
-WebGLFramebufferAttachable::AttachmentPoint*
-WebGLFramebufferAttachable::Contains(const WebGLFramebuffer* fb, GLenum attachment)
-{
-    AttachmentPoint* first = mAttachmentPoints.begin();
-    AttachmentPoint* last = mAttachmentPoints.end();
-
-    for (; first != last; ++first) {
-        if (first->mFB == fb && first->mAttachment == attachment)
-            return first;
-    }
-
-    return nullptr;
-}
-
 void
 WebGLFramebufferAttachable::AttachTo(WebGLFramebuffer* fb, GLenum attachment)
 {
     MOZ_ASSERT(fb);
     if (!fb)
         return;
 
-    if (Contains(fb, attachment))
+    if (mAttachmentPoints.Contains(AttachmentPoint(fb, attachment)))
         return; // Already attached. Ignore.
 
-    mAttachmentPoints.append(AttachmentPoint(fb, attachment));
+    mAttachmentPoints.AppendElement(AttachmentPoint(fb, attachment));
 }
 
 void
 WebGLFramebufferAttachable::DetachFrom(WebGLFramebuffer* fb, GLenum attachment)
 {
     MOZ_ASSERT(fb);
     if (!fb)
         return;
 
-    AttachmentPoint* point = Contains(fb, attachment);
-    if (!point) {
+    const size_t i = mAttachmentPoints.IndexOf(AttachmentPoint(fb, attachment));
+    if (i == mAttachmentPoints.NoIndex) {
         MOZ_ASSERT(false, "Is not attached to FB");
         return;
     }
 
-    mAttachmentPoints.erase(point);
+    mAttachmentPoints.RemoveElementAt(i);
 }
 
 void
 WebGLFramebufferAttachable::NotifyFBsStatusChanged()
 {
-    AttachmentPoint* first = mAttachmentPoints.begin();
-    AttachmentPoint* last = mAttachmentPoints.end();
-    for ( ; first != last; ++first)
-        first->mFB->NotifyAttachableChanged();
+    for (size_t i = 0; i < mAttachmentPoints.Length(); ++i)
+        mAttachmentPoints[i].mFB->NotifyAttachableChanged();
 }
--- a/dom/canvas/WebGLFramebufferAttachable.h
+++ b/dom/canvas/WebGLFramebufferAttachable.h
@@ -2,38 +2,40 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef WEBGLFRAMEBUFFERATTACHABLE_H_
 #define WEBGLFRAMEBUFFERATTACHABLE_H_
 
 #include "GLDefs.h"
-#include "mozilla/Vector.h"
+#include "nsTArray.h"
 
 namespace mozilla {
 
 class WebGLFramebuffer;
 
 class WebGLFramebufferAttachable
 {
     struct AttachmentPoint
     {
         AttachmentPoint(const WebGLFramebuffer* fb, GLenum attachment)
             : mFB(fb)
             , mAttachment(attachment)
         {}
 
         const WebGLFramebuffer* mFB;
         GLenum mAttachment;
+
+        bool operator==(const AttachmentPoint& o) const {
+          return mFB == o.mFB && mAttachment == o.mAttachment;
+        }
     };
 
-    Vector<AttachmentPoint> mAttachmentPoints;
-
-    AttachmentPoint* Contains(const WebGLFramebuffer* fb, GLenum attachment);
+    nsTArray<AttachmentPoint> mAttachmentPoints;
 
 public:
 
     // Track FBO/Attachment combinations
     void AttachTo(WebGLFramebuffer* fb, GLenum attachment);
     void DetachFrom(WebGLFramebuffer* fb, GLenum attachment);
     void NotifyFBsStatusChanged();
 };