Skip to content

Commit f5a921f

Browse files
NickGerlemanmeta-codesync[bot]
authored andcommitted
Remove redundant operator!= definitions in react-native-github (#55746)
Summary: Pull Request resolved: #55746 X-link: facebook/yoga#1892 C++20 automatically generates `operator!=` from `operator==`, making explicit `operator!=` definitions redundant. This removes all such redundant definitions across the React Native C++ codebase, including: - Simple negation patterns (`return !(*this == rhs)`) - Explicit `= default` declarations that duplicate the compiler-generated behavior - Both member and free-function forms Files in jsi/ were excluded as they are mirrored to a project that may not support C++20. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D94370249 fbshipit-source-id: f1c73d38a61ff9e780bd16a797e6ce71b1900d00
1 parent 9cff12c commit f5a921f

44 files changed

Lines changed: 0 additions & 210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/react-native/Libraries/FBLazyVector/FBLazyVector/FBLazyIterator.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,6 @@ LazyIterator<T, U> operator+(typename LazyIterator<T, U>::difference_type n, con
116116
return i + n;
117117
}
118118

119-
template <typename T, typename U>
120-
bool operator!=(const LazyIterator<T, U> &a, const LazyIterator<T, U> &b)
121-
{
122-
return !(a == b);
123-
}
124-
125119
template <typename T, typename U>
126120
bool operator<=(const LazyIterator<T, U> &a, const LazyIterator<T, U> &b)
127121
{

packages/react-native/ReactCommon/jsinspector-modern/UniqueMonostate.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ struct UniqueMonostate {
2222
{
2323
return true;
2424
}
25-
constexpr bool operator!=(const UniqueMonostate<key> & /*unused*/) const noexcept
26-
{
27-
return false;
28-
}
2925
constexpr bool operator<(const UniqueMonostate<key> & /*unused*/) const noexcept
3026
{
3127
return false;

packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,4 @@ bool operator==(
7979
}
8080
}
8181

82-
bool operator!=(
83-
const AttributedStringBox& lhs,
84-
const AttributedStringBox& rhs) {
85-
return !(lhs == rhs);
86-
}
87-
8882
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/attributedstring/AttributedStringBox.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ class AttributedStringBox final {
5858
};
5959

6060
bool operator==(const AttributedStringBox &lhs, const AttributedStringBox &rhs);
61-
bool operator!=(const AttributedStringBox &lhs, const AttributedStringBox &rhs);
6261

6362
} // namespace facebook::react
6463

packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ bool ParagraphAttributes::operator==(const ParagraphAttributes& rhs) const {
3636
floatEquality(minimumFontScale, rhs.minimumFontScale);
3737
}
3838

39-
bool ParagraphAttributes::operator!=(const ParagraphAttributes& rhs) const {
40-
return !(*this == rhs);
41-
}
42-
4339
#pragma mark - DebugStringConvertible
4440

4541
#if RN_DEBUG_STRING_CONVERTIBLE

packages/react-native/ReactCommon/react/renderer/attributedstring/ParagraphAttributes.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,6 @@ class ParagraphAttributes : public DebugStringConvertible {
8383
std::optional<TextAlignmentVertical> textAlignVertical{};
8484

8585
bool operator==(const ParagraphAttributes &rhs) const;
86-
bool operator!=(const ParagraphAttributes &rhs) const;
8786

8887
#pragma mark - DebugStringConvertible
8988

packages/react-native/ReactCommon/react/renderer/components/scrollview/primitives.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,6 @@ class ScrollViewMaintainVisibleContentPosition final {
3030
return std::tie(this->minIndexForVisible, this->autoscrollToTopThreshold) ==
3131
std::tie(rhs.minIndexForVisible, rhs.autoscrollToTopThreshold);
3232
}
33-
34-
bool operator!=(const ScrollViewMaintainVisibleContentPosition &rhs) const
35-
{
36-
return !(*this == rhs);
37-
}
3833
};
3934

4035
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/components/view/AccessibilityPrimitives.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,6 @@ inline static bool operator==(const AccessibilityAction &lhs, const Accessibilit
5656
return lhs.name == rhs.name && lhs.label == rhs.label;
5757
}
5858

59-
inline static bool operator!=(const AccessibilityAction &lhs, const AccessibilityAction &rhs)
60-
{
61-
return !(rhs == lhs);
62-
}
63-
6459
struct AccessibilityState {
6560
bool disabled{false};
6661
bool selected{false};
@@ -76,11 +71,6 @@ constexpr bool operator==(const AccessibilityState &lhs, const AccessibilityStat
7671
lhs.busy == rhs.busy && lhs.expanded == rhs.expanded;
7772
}
7873

79-
constexpr bool operator!=(const AccessibilityState &lhs, const AccessibilityState &rhs)
80-
{
81-
return !(rhs == lhs);
82-
}
83-
8474
struct AccessibilityLabelledBy {
8575
std::vector<std::string> value{};
8676
};
@@ -90,11 +80,6 @@ inline static bool operator==(const AccessibilityLabelledBy &lhs, const Accessib
9080
return lhs.value == rhs.value;
9181
}
9282

93-
inline static bool operator!=(const AccessibilityLabelledBy &lhs, const AccessibilityLabelledBy &rhs)
94-
{
95-
return !(lhs == rhs);
96-
}
97-
9883
struct AccessibilityValue {
9984
std::optional<int> min;
10085
std::optional<int> max;
@@ -107,11 +92,6 @@ constexpr bool operator==(const AccessibilityValue &lhs, const AccessibilityValu
10792
return lhs.min == rhs.min && lhs.max == rhs.max && lhs.now == rhs.now && lhs.text == rhs.text;
10893
}
10994

110-
constexpr bool operator!=(const AccessibilityValue &lhs, const AccessibilityValue &rhs)
111-
{
112-
return !(rhs == lhs);
113-
}
114-
11595
enum class ImportantForAccessibility : uint8_t {
11696
Auto,
11797
Yes,

packages/react-native/ReactCommon/react/renderer/components/view/primitives.h

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ inline static bool operator==(const ViewEvents &lhs, const ViewEvents &rhs)
8585
return lhs.bits == rhs.bits;
8686
}
8787

88-
inline static bool operator!=(const ViewEvents &lhs, const ViewEvents &rhs)
89-
{
90-
return lhs.bits != rhs.bits;
91-
}
92-
9388
enum class BackfaceVisibility : uint8_t { Auto, Visible, Hidden };
9489

9590
enum class BorderCurve : uint8_t { Circular, Continuous };
@@ -212,11 +207,6 @@ struct CascadedRectangleEdges {
212207
rhs.blockStart,
213208
rhs.blockEnd);
214209
}
215-
216-
bool operator!=(const CascadedRectangleEdges<T> &rhs) const
217-
{
218-
return !(*this == rhs);
219-
}
220210
};
221211

222212
template <typename T>
@@ -292,11 +282,6 @@ struct CascadedRectangleCorners {
292282
rhs.startEnd,
293283
rhs.startStart);
294284
}
295-
296-
bool operator!=(const CascadedRectangleCorners<T> &rhs) const
297-
{
298-
return !(*this == rhs);
299-
}
300285
};
301286

302287
using BorderWidths = RectangleEdges<Float>;
@@ -324,11 +309,6 @@ struct BorderMetrics {
324309
this->borderColors, this->borderWidths, this->borderRadii, this->borderCurves, this->borderStyles) ==
325310
std::tie(rhs.borderColors, rhs.borderWidths, rhs.borderRadii, rhs.borderCurves, rhs.borderStyles);
326311
}
327-
328-
bool operator!=(const BorderMetrics &rhs) const
329-
{
330-
return !(*this == rhs);
331-
}
332312
};
333313

334314
} // namespace facebook::react

packages/react-native/ReactCommon/react/renderer/core/LayoutConstraints.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@ inline bool operator==(const LayoutConstraints &lhs, const LayoutConstraints &rh
3636
std::tie(rhs.minimumSize, rhs.maximumSize, rhs.layoutDirection);
3737
}
3838

39-
inline bool operator!=(const LayoutConstraints &lhs, const LayoutConstraints &rhs)
40-
{
41-
return !(lhs == rhs);
42-
}
43-
4439
} // namespace facebook::react
4540

4641
namespace std {

0 commit comments

Comments
 (0)