Title: [141932] trunk/Source/WTF
Revision
141932
Author
[email protected]
Date
2013-02-05 14:14:50 -0800 (Tue, 05 Feb 2013)

Log Message

Tidy up StackBounds
https://bugs.webkit.org/show_bug.cgi?id=108889

Patch by Benjamin Poulain <[email protected]> on 2013-02-05
Reviewed by Ryosuke Niwa.

* wtf/StackBounds.h:
(StackBounds):
(WTF::StackBounds::isSafeToRecurse):
(WTF::StackBounds::size):
Adopt a more conventional style for a multiline branch.

(WTF::StackBounds::StackBounds):
(WTF::StackBounds::current):
(WTF::StackBounds::recursionLimit):
Make those method private.

Making the constructor private ensure initialize() is alwasy called on any StackBounds.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (141931 => 141932)


--- trunk/Source/WTF/ChangeLog	2013-02-05 22:14:31 UTC (rev 141931)
+++ trunk/Source/WTF/ChangeLog	2013-02-05 22:14:50 UTC (rev 141932)
@@ -1,3 +1,23 @@
+2013-02-05  Benjamin Poulain  <[email protected]>
+
+        Tidy up StackBounds
+        https://bugs.webkit.org/show_bug.cgi?id=108889
+
+        Reviewed by Ryosuke Niwa.
+
+        * wtf/StackBounds.h:
+        (StackBounds):
+        (WTF::StackBounds::isSafeToRecurse):
+        (WTF::StackBounds::size):
+        Adopt a more conventional style for a multiline branch.
+
+        (WTF::StackBounds::StackBounds):
+        (WTF::StackBounds::current):
+        (WTF::StackBounds::recursionLimit):
+        Make those method private.
+
+        Making the constructor private ensure initialize() is alwasy called on any StackBounds.
+
 2013-02-05  Zan Dobersek  <[email protected]>
 
         [WTFURL] Comparison between signed and unsigned integer expressions in URLUtil.cpp

Modified: trunk/Source/WTF/wtf/StackBounds.h (141931 => 141932)


--- trunk/Source/WTF/wtf/StackBounds.h	2013-02-05 22:14:31 UTC (rev 141931)
+++ trunk/Source/WTF/wtf/StackBounds.h	2013-02-05 22:14:50 UTC (rev 141932)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All Rights Reserved.
+ * Copyright (C) 2010, 2013 Apple Inc. All Rights Reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -41,12 +41,6 @@
     const static size_t s_defaultAvailabilityDelta = 64 * 1024;
 
 public:
-    StackBounds()
-        : m_origin(0)
-        , m_bound(0)
-    {
-    }
-
     static StackBounds currentThreadStackBounds()
     {
         StackBounds bounds;
@@ -55,46 +49,51 @@
         return bounds;
     }
 
+    bool isSafeToRecurse(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
+    {
+        checkConsistency();
+        if (isGrowingDownward())
+            return current() >= recursionLimit(minAvailableDelta);
+        return current() <= recursionLimit(minAvailableDelta);
+    }
+
     void* origin() const
     {
         ASSERT(m_origin);
         return m_origin;
     }
 
-    void* current() const
+    size_t size() const
     {
-        checkConsistency();
-        void* currentPosition = &currentPosition;
-        return currentPosition;
+        if (isGrowingDownward())
+            return static_cast<char*>(m_origin) - static_cast<char*>(m_bound);
+        return static_cast<char*>(m_bound) - static_cast<char*>(m_origin);
     }
 
-    size_t size() const
+private:
+    StackBounds()
+        : m_origin(0)
+        , m_bound(0)
     {
-        return isGrowingDownward()
-            ? static_cast<char*>(m_origin) - static_cast<char*>(m_bound)
-            : static_cast<char*>(m_bound) - static_cast<char*>(m_origin);
     }
 
-    void* recursionLimit(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
+    void initialize();
+
+    void* current() const
     {
         checkConsistency();
-        return isGrowingDownward()
-            ? static_cast<char*>(m_bound) + minAvailableDelta
-            : static_cast<char*>(m_bound) - minAvailableDelta;
+        void* currentPosition = &currentPosition;
+        return currentPosition;
     }
 
-    bool isSafeToRecurse(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
+    void* recursionLimit(size_t minAvailableDelta = s_defaultAvailabilityDelta) const
     {
         checkConsistency();
-        return isGrowingDownward()
-            ? current() >= recursionLimit(minAvailableDelta)
-            : current() <= recursionLimit(minAvailableDelta);
+        if (isGrowingDownward())
+            return static_cast<char*>(m_bound) + minAvailableDelta;
+        return static_cast<char*>(m_bound) - minAvailableDelta;
     }
 
-private:
-    void initialize();
-
-
     bool isGrowingDownward() const
     {
         ASSERT(m_origin && m_bound);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to