Fabric: Making Sealable debug-only thing
Summary: @public Now, Sealable is already error-preventing-only mechanism, no business logic relies on that. So, it makes sense to make it debug-only to illuminate possible performance impact. Reviewed By: mdvacca Differential Revision: D8923597 fbshipit-source-id: 80aa9097c4b719e91de73ac59f38d3a4751f0b06
This commit is contained in:
parent
da6a5e0439
commit
5d0b51b107
|
@ -24,6 +24,8 @@ namespace react {
|
||||||
* http://en.cppreference.com/w/cpp/language/rule_of_three
|
* http://en.cppreference.com/w/cpp/language/rule_of_three
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
Sealable::Sealable(): sealed_(false) {}
|
Sealable::Sealable(): sealed_(false) {}
|
||||||
|
|
||||||
Sealable::Sealable(const Sealable &other): sealed_(false) {};
|
Sealable::Sealable(const Sealable &other): sealed_(false) {};
|
||||||
|
@ -40,7 +42,7 @@ Sealable &Sealable::operator=(const Sealable &other) {
|
||||||
Sealable &Sealable::operator=(Sealable &&other) noexcept {
|
Sealable &Sealable::operator=(Sealable &&other) noexcept {
|
||||||
ensureUnsealed();
|
ensureUnsealed();
|
||||||
return *this;
|
return *this;
|
||||||
};
|
}
|
||||||
|
|
||||||
void Sealable::seal() const {
|
void Sealable::seal() const {
|
||||||
sealed_ = true;
|
sealed_ = true;
|
||||||
|
@ -56,5 +58,7 @@ void Sealable::ensureUnsealed() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace react
|
} // namespace react
|
||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
|
|
@ -40,6 +40,18 @@ namespace react {
|
||||||
* 3. Call `seal()` at some point from which any modifications
|
* 3. Call `seal()` at some point from which any modifications
|
||||||
* must be prevented.
|
* must be prevented.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#ifdef NDEBUG
|
||||||
|
|
||||||
|
class Sealable {
|
||||||
|
public:
|
||||||
|
inline void seal() const {}
|
||||||
|
inline bool getSealed() const { return true; }
|
||||||
|
inline void ensureUnsealed() const {}
|
||||||
|
};
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
class Sealable {
|
class Sealable {
|
||||||
public:
|
public:
|
||||||
Sealable();
|
Sealable();
|
||||||
|
@ -70,5 +82,7 @@ private:
|
||||||
mutable std::atomic<bool> sealed_ {false};
|
mutable std::atomic<bool> sealed_ {false};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
} // namespace react
|
} // namespace react
|
||||||
} // namespace facebook
|
} // namespace facebook
|
||||||
|
|
Loading…
Reference in New Issue