Bug 1317588 Part 5 - Change Side's operator++ from postfix to prefix. draft
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 23 Nov 2016 16:55:04 +0800
changeset 442819 93f93c8fee1f68bb240eee4749adc592d6825364
parent 442818 0a3b9f0b135b998fd37a8b68d40c94b34ade7a28
child 537894 40ac655a1e56030ec69328ae9ee71c0d834b6aa1
push id36823
push userbmo:tlin@mozilla.com
push dateWed, 23 Nov 2016 08:57:12 +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. MozReview-Commit-ID: GbdB2ZC9KyW
gfx/2d/Types.h
--- a/gfx/2d/Types.h
+++ b/gfx/2d/Types.h
@@ -402,19 +402,19 @@ enum SideBits {
 // We use an int32_t helper variable (instead of a Side) for our loop counter,
 // to avoid triggering undefined behavior just before we exit the loop (at
 // which point the counter is incremented beyond the largest valid Side value).
 #define NS_FOR_CSS_SIDES(var_)                                           \
   int32_t MOZ_CONCAT(var_,__LINE__) = mozilla::eSideTop;                 \
   for (mozilla::Side var_;                                               \
        MOZ_CONCAT(var_,__LINE__) <= mozilla::eSideLeft &&                \
          ((var_ = mozilla::Side(MOZ_CONCAT(var_,__LINE__))), true);      \
-       MOZ_CONCAT(var_,__LINE__)++)
+       ++MOZ_CONCAT(var_,__LINE__))
 
-static inline Side operator++(Side& side, int) {
+static inline Side& operator++(Side& side) {
   MOZ_ASSERT(side >= eSideTop && side <= eSideLeft,
              "Out of range side");
   side = Side(side + 1);
   return side;
 }
 
 } // namespace mozilla