mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Fabric: operator== and std::hash for AttributedStringBox
Summary: That will allow building a custom caching table for boxed stings to cache text measurements for them in TextLayoutManager. Changelog: [Internal] Fabric-specific internal change. Reviewed By: sammy-SC Differential Revision: D18950428 fbshipit-source-id: 8ceef29543dc6ed540043e32d65f3295030ae90f
This commit is contained in:
committed by
Facebook Github Bot
parent
3b92d3187c
commit
909b0fe0e7
@@ -40,5 +40,26 @@ std::shared_ptr<void> AttributedStringBox::getOpaquePointer() const {
|
||||
return opaquePointer_;
|
||||
}
|
||||
|
||||
bool operator==(
|
||||
AttributedStringBox const &lhs,
|
||||
AttributedStringBox const &rhs) {
|
||||
if (lhs.getMode() != rhs.getMode()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
switch (lhs.getMode()) {
|
||||
case facebook::react::AttributedStringBox::Mode::Value:
|
||||
return lhs.getValue() == rhs.getValue();
|
||||
case facebook::react::AttributedStringBox::Mode::OpaquePointer:
|
||||
return lhs.getOpaquePointer() == rhs.getOpaquePointer();
|
||||
}
|
||||
}
|
||||
|
||||
bool operator!=(
|
||||
AttributedStringBox const &lhs,
|
||||
AttributedStringBox const &rhs) {
|
||||
return !(lhs == rhs);
|
||||
}
|
||||
|
||||
} // namespace react
|
||||
} // namespace facebook
|
||||
|
||||
Reference in New Issue
Block a user