diff --git a/ReactCommon/fabric/attributedstring/AttributedString.h b/ReactCommon/fabric/attributedstring/AttributedString.h index 5e09cd34e..2178e62f8 100644 --- a/ReactCommon/fabric/attributedstring/AttributedString.h +++ b/ReactCommon/fabric/attributedstring/AttributedString.h @@ -91,10 +91,12 @@ struct hash { size_t operator()( const facebook::react::AttributedString::Fragment &fragment) const { auto seed = size_t{0}; - folly::hash::hash_combine(seed, fragment.string); - folly::hash::hash_combine(seed, fragment.textAttributes); - folly::hash::hash_combine(seed, fragment.shadowView); - folly::hash::hash_combine(seed, fragment.parentShadowView); + folly::hash::hash_combine( + seed, + fragment.string, + fragment.textAttributes, + fragment.shadowView, + fragment.parentShadowView); return seed; } }; diff --git a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h index 36e645e5d..6f0738d66 100644 --- a/ReactCommon/fabric/attributedstring/ParagraphAttributes.h +++ b/ReactCommon/fabric/attributedstring/ParagraphAttributes.h @@ -73,15 +73,15 @@ template <> struct hash { size_t operator()( const facebook::react::ParagraphAttributes &attributes) const { - size_t seed = 0; - folly::hash::hash_combine(seed, attributes.maximumNumberOfLines); - folly::hash::hash_combine(seed, attributes.ellipsizeMode); - folly::hash::hash_combine(seed, attributes.adjustsFontSizeToFit); + auto seed = size_t{0}; folly::hash::hash_combine( - seed, std::hash{}(attributes.minimumFontSize)); - folly::hash::hash_combine( - seed, std::hash{}(attributes.maximumFontSize)); - return hash()(seed); + seed, + attributes.maximumNumberOfLines, + attributes.ellipsizeMode, + attributes.adjustsFontSizeToFit, + attributes.minimumFontSize, + attributes.maximumFontSize); + return seed; } }; } // namespace std diff --git a/ReactCommon/fabric/attributedstring/TextAttributes.h b/ReactCommon/fabric/attributedstring/TextAttributes.h index 6340143d9..feb1c1e77 100644 --- a/ReactCommon/fabric/attributedstring/TextAttributes.h +++ b/ReactCommon/fabric/attributedstring/TextAttributes.h @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -92,55 +93,38 @@ class TextAttributes : public DebugStringConvertible { } // namespace facebook namespace std { + template <> struct hash { size_t operator()( const facebook::react::TextAttributes &textAttributes) const { - return std::hash{}( - textAttributes.foregroundColor) + - std::hash{}( - textAttributes.backgroundColor) + - std::hash{}(textAttributes.opacity) + - std::hash{}( - textAttributes.fontFamily) + - std::hash{}( - textAttributes.fontSize) + - std::hash{}( - textAttributes.fontSizeMultiplier) + - std::hash{}( - textAttributes.fontWeight) + - std::hash{}( - textAttributes.fontStyle) + - std::hash{}( - textAttributes.fontVariant) + - std::hash{}( - textAttributes.allowFontScaling) + - std::hash{}( - textAttributes.letterSpacing) + - std::hash{}( - textAttributes.lineHeight) + - std::hash{}( - textAttributes.alignment) + - std::hash{}( - textAttributes.baseWritingDirection) + - std::hash{}( - textAttributes.textDecorationColor) + - std::hash{}( - textAttributes.textDecorationLineType) + - std::hash{}( - textAttributes.textDecorationLineStyle) + - std::hash{}( - textAttributes.textDecorationLinePattern) + - std::hash{}( - textAttributes.textShadowOffset) + - std::hash{}( - textAttributes.textShadowRadius) + - std::hash{}( - textAttributes.textShadowColor) + - std::hash{}( - textAttributes.isHighlighted) + - std::hash{}( - textAttributes.layoutDirection); + auto seed = size_t{0}; + folly::hash::hash_combine( + seed, + textAttributes.foregroundColor, + textAttributes.backgroundColor, + textAttributes.opacity, + textAttributes.fontFamily, + textAttributes.fontSize, + textAttributes.fontSizeMultiplier, + textAttributes.fontWeight, + textAttributes.fontStyle, + textAttributes.fontVariant, + textAttributes.allowFontScaling, + textAttributes.letterSpacing, + textAttributes.lineHeight, + textAttributes.alignment, + textAttributes.baseWritingDirection, + textAttributes.textDecorationColor, + textAttributes.textDecorationLineType, + textAttributes.textDecorationLineStyle, + textAttributes.textDecorationLinePattern, + textAttributes.textShadowOffset, + textAttributes.textShadowRadius, + textAttributes.textShadowColor, + textAttributes.isHighlighted, + textAttributes.layoutDirection); + return seed; } }; } // namespace std diff --git a/ReactCommon/fabric/core/layout/LayoutConstraints.h b/ReactCommon/fabric/core/layout/LayoutConstraints.h index 1d54a0594..d4f79bf5b 100644 --- a/ReactCommon/fabric/core/layout/LayoutConstraints.h +++ b/ReactCommon/fabric/core/layout/LayoutConstraints.h @@ -36,14 +36,15 @@ inline bool operator==( namespace std { template <> struct hash { - size_t operator()(const facebook::react::LayoutConstraints &v) const { - size_t seed = 0; + size_t operator()( + const facebook::react::LayoutConstraints &constraints) const { + auto seed = size_t{0}; folly::hash::hash_combine( - seed, std::hash()(v.minimumSize)); - folly::hash::hash_combine( - seed, std::hash()(v.maximumSize)); - folly::hash::hash_combine(seed, v.layoutDirection); - return hash()(seed); + seed, + constraints.minimumSize, + constraints.maximumSize, + constraints.layoutDirection); + return seed; } }; } // namespace std diff --git a/ReactCommon/fabric/graphics/Geometry.h b/ReactCommon/fabric/graphics/Geometry.h index df491e4a1..0cc3fe4a6 100644 --- a/ReactCommon/fabric/graphics/Geometry.h +++ b/ReactCommon/fabric/graphics/Geometry.h @@ -9,6 +9,7 @@ #include #include +#include #include namespace facebook { @@ -185,44 +186,51 @@ namespace std { template <> struct hash { size_t operator()(const facebook::react::Point &point) const { - return hash{}(point.x) + - hash{}(point.y); + auto seed = size_t{0}; + folly::hash::hash_combine(seed, point.x, point.y); + return seed; } }; template <> struct hash { size_t operator()(const facebook::react::Size &size) const { - return hash{}(size.width) + - hash{}(size.height); + auto seed = size_t{0}; + folly::hash::hash_combine(seed, size.width, size.height); + return seed; } }; template <> struct hash { size_t operator()(const facebook::react::Rect &rect) const { - return hash{}(rect.origin) + - hash{}(rect.size); + auto seed = size_t{0}; + folly::hash::hash_combine(seed, rect.origin, rect.size); + return seed; } }; template struct hash> { size_t operator()(const facebook::react::RectangleEdges &edges) const { - return hash{}(edges.left) + - hash{}(edges.right) + - hash{}(edges.top) + - hash{}(edges.bottom); + auto seed = size_t{0}; + folly::hash::hash_combine( + seed, edges.left, edges.right, edges.top, edges.bottom); + return seed; } }; template struct hash> { size_t operator()(const facebook::react::RectangleCorners &corners) const { - return hash{}(corners.topLeft) + - hash{}(corners.bottomLeft) + - hash{}(corners.topRight) + - hash{}(corners.bottomRight); + auto seed = size_t{0}; + folly::hash::hash_combine( + seed, + corners.topLeft, + corners.bottomLeft, + corners.topRight, + corners.bottomRight); + return seed; } }; diff --git a/ReactCommon/fabric/mounting/ShadowView.h b/ReactCommon/fabric/mounting/ShadowView.h index a01c74a93..8f242effa 100644 --- a/ReactCommon/fabric/mounting/ShadowView.h +++ b/ReactCommon/fabric/mounting/ShadowView.h @@ -5,6 +5,7 @@ #pragma once +#include #include #include #include @@ -65,13 +66,15 @@ namespace std { template <> struct hash { size_t operator()(const facebook::react::ShadowView &shadowView) const { - return std::hash{}( - shadowView.componentHandle) + - std::hash{}(shadowView.tag) + - std::hash{}(shadowView.props) + - std::hash{}( - shadowView.eventEmitter) + - std::hash{}(shadowView.localData); + auto seed = size_t{0}; + folly::hash::hash_combine( + seed, + shadowView.componentHandle, + shadowView.tag, + shadowView.props, + shadowView.eventEmitter, + shadowView.localData); + return seed; } };