Bug 1317588 Part 5 - Change Side's operator++ from postfix to prefix. draft
authorTing-Yu Lin <tlin@mozilla.com>
Mon, 21 Nov 2016 10:58:56 +0800
changeset 442412 64a87d9e6e9bff330f1718a8e10992e9579d96c0
parent 442411 b2335e325c3f8c6bc69a3a8384b73ebf8a383a85
child 442413 87fb33714e4b5a40f79a06cf25fdce2ded0b5286
push id36704
push userbmo:tlin@mozilla.com
push dateTue, 22 Nov 2016 14:39:32 +0000
bugs1317588
milestone53.0a1
Bug 1317588 Part 5 - Change Side's operator++ from postfix to prefix. The postfix operator++ was actually incorrectly implemented as a prefix version. Since it's only used in NS_FOR_CSS_SIDES, let's changed it to prefix version and gain some performance improvement. MozReview-Commit-ID: 6p4yv5Nylqj
gfx/2d/Types.h
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -402,20 +402,19 @@ enum SideBits {
   eSideBitsLeftRight = eSideBitsLeft | eSideBitsRight,
   eSideBitsAll = eSideBitsTopBottom | eSideBitsLeftRight
 };
 
 // Creates a for loop that walks over the first four mozilla::Side values.
 #define NS_FOR_CSS_SIDES(var_)                                           \
   for (mozilla::Side var_ = mozilla::eSideTop;                           \
        var_ <= mozilla::eSideLeft;                                       \
-       var_++)
+       ++var_)
 
-static inline Side operator++(Side& side, int) {
+static inline Side& operator++(Side& side) {
   MOZ_ASSERT(side >= mozilla::eSideTop && side <= mozilla::eSideLeft,
              "Out of range side");
-  side = Side(side + 1);
-  return side;
+  return ++side;
 }
 
 } // namespace mozilla
 
 #endif /* MOZILLA_GFX_TYPES_H_ */