Backed out changeset c82274a23aea (bug 1410186) on request by igoldan a=backout
authorBogdan Tara <btara@mozilla.com>
Mon, 21 May 2018 16:53:30 +0300
changeset 419125 77c06979d9e88979ec96263eccdbd750cb9221a4
parent 419124 dc1868d255be744a7d2d462216be205086cc60af
child 419137 6e571fd8686390e3d870a97e38f54ea69cfcf0b7
child 419163 e46cb2927af94344fd03989d336a06115f81d8e1
push id34027
push userbtara@mozilla.com
push dateMon, 21 May 2018 13:54:04 +0000
treeherdermozilla-central@77c06979d9e8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1410186
milestone62.0a1
backs outc82274a23aeaa6be8b7509de05822cb4bfa7729e
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
Backed out changeset c82274a23aea (bug 1410186) on request by igoldan a=backout
mfbt/Maybe.h
--- a/mfbt/Maybe.h
+++ b/mfbt/Maybe.h
@@ -310,17 +310,21 @@ public:
   }
 
   /* Methods that check whether this Maybe contains a value */
   explicit operator bool() const { return isSome(); }
   bool isSome() const { return mIsSome; }
   bool isNothing() const { return !mIsSome; }
 
   /* Returns the contents of this Maybe<T> by value. Unsafe unless |isSome()|. */
-  T value() const;
+  T value() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
 
   /*
    * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns
    * the default value provided.
    */
   template<typename V>
   T valueOr(V&& aDefault) const
   {
@@ -339,18 +343,27 @@ public:
   {
     if (isSome()) {
       return ref();
     }
     return aFunc();
   }
 
   /* Returns the contents of this Maybe<T> by pointer. Unsafe unless |isSome()|. */
-  T* ptr();
-  const T* ptr() const;
+  T* ptr()
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
+
+  const T* ptr() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return &ref();
+  }
 
   /*
    * Returns the contents of this Maybe<T> by pointer. If |isNothing()|,
    * returns the default value provided.
    */
   T* ptrOr(T* aDefault)
   {
     if (isSome()) {
@@ -384,22 +397,40 @@ public:
   const T* ptrOrFrom(F&& aFunc) const
   {
     if (isSome()) {
       return ptr();
     }
     return aFunc();
   }
 
-  T* operator->();
-  const T* operator->() const;
+  T* operator->()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
+
+  const T* operator->() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ptr();
+  }
 
   /* Returns the contents of this Maybe<T> by ref. Unsafe unless |isSome()|. */
-  T& ref();
-  const T& ref() const;
+  T& ref()
+  {
+    MOZ_ASSERT(mIsSome);
+    return *static_cast<T*>(data());
+  }
+
+  const T& ref() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return *static_cast<const T*>(data());
+  }
 
   /*
    * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns
    * the default value provided.
    */
   T& refOr(T& aDefault)
   {
     if (isSome()) {
@@ -433,18 +464,27 @@ public:
   const T& refOrFrom(F&& aFunc) const
   {
     if (isSome()) {
       return ref();
     }
     return aFunc();
   }
 
-  T& operator*();
-  const T& operator*() const;
+  T& operator*()
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
+
+  const T& operator*() const
+  {
+    MOZ_ASSERT(mIsSome);
+    return ref();
+  }
 
   /* If |isSome()|, runs the provided function or functor on the contents of
    * this Maybe. */
   template<typename Func>
   Maybe& apply(Func aFunc)
   {
     if (isSome()) {
       aFunc(ref());
@@ -499,112 +539,35 @@ public:
     }
   }
 
   /*
    * Constructs a T value in-place in this empty Maybe<T>'s storage. The
    * arguments to |emplace()| are the parameters to T's constructor.
    */
   template<typename... Args>
-  void emplace(Args&&... aArgs);
+  void emplace(Args&&... aArgs)
+  {
+    MOZ_ASSERT(!mIsSome);
+    ::new (KnownNotNull, data()) T(Forward<Args>(aArgs)...);
+    mIsSome = true;
+  }
 
   friend std::ostream&
   operator<<(std::ostream& aStream, const Maybe<T>& aMaybe)
   {
     if (aMaybe) {
       aStream << aMaybe.ref();
     } else {
       aStream << "<Nothing>";
     }
     return aStream;
   }
 };
 
-template<typename T>
-T
-Maybe<T>::value() const
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-T*
-Maybe<T>::ptr()
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return &ref();
-}
-
-template<typename T>
-const T*
-Maybe<T>::ptr() const
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return &ref();
-}
-
-template<typename T>
-T*
-Maybe<T>::operator->()
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return ptr();
-}
-
-template<typename T>
-const T*
-Maybe<T>::operator->() const
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return ptr();
-}
-
-template<typename T>
-T&
-Maybe<T>::ref()
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return *static_cast<T*>(data());
-}
-
-template<typename T>
-const T&
-Maybe<T>::ref() const
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return *static_cast<const T*>(data());
-}
-
-template<typename T>
-T&
-Maybe<T>::operator*()
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-const T&
-Maybe<T>::operator*() const
-{
-  MOZ_DIAGNOSTIC_ASSERT(mIsSome);
-  return ref();
-}
-
-template<typename T>
-template<typename... Args>
-void
-Maybe<T>::emplace(Args&&... aArgs)
-{
-  MOZ_DIAGNOSTIC_ASSERT(!mIsSome);
-  ::new (KnownNotNull, data()) T(Forward<Args>(aArgs)...);
-  mIsSome = true;
-}
-
 /*
  * Some() creates a Maybe<T> value containing the provided T value. If T has a
  * move constructor, it's used to make this as efficient as possible.
  *
  * Some() selects the type of Maybe it returns by removing any const, volatile,
  * or reference qualifiers from the type of the value you pass to it. This gives
  * it more intuitive behavior when used in expressions, but it also means that
  * if you need to construct a Maybe value that holds a const, volatile, or