Skip to content

Commit 79b9b25

Browse files
cyyevermeta-codesync[bot]
authored andcommitted
Use C++20 [[unlikely]] and defaulted operator== (#5630)
Summary: X-link: https://github.com/facebookresearch/FBGEMM/pull/2581 Pull Request resolved: #5630 Reviewed By: cthi Differential Revision: D100759719 Pulled By: q10 fbshipit-source-id: 4f81a8193c6f90ddc4370de2a51e9b0465e5f4d1
1 parent 0aacd9f commit 79b9b25

2 files changed

Lines changed: 2 additions & 16 deletions

File tree

include/fbgemm/Assert.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,8 @@ auto fbgemmCheckMsg(const char* defaultMsg, const Args&... args) {
6767
// unceremoniously quit the process (unlike assert()).
6868
////////////////////////////////////////////////////////////////////////////////
6969

70-
#if defined(__GNUC__) || defined(__ICL) || defined(__clang__)
71-
#define FBGEMM_UNLIKELY(expr) (__builtin_expect(static_cast<bool>(expr), 0))
72-
#else
73-
#define FBGEMM_UNLIKELY(expr) (expr)
74-
#endif
75-
7670
#define FBGEMM_CHECK(cond, ...) \
77-
if (FBGEMM_UNLIKELY(!(cond))) { \
71+
if (!(cond)) [[unlikely]] { \
7872
throw ::fbgemm::Error( \
7973
::fbgemm::detail::fbgemmCheckMsg( \
8074
"Expected " #cond " to be true, but got false. " \

src/EmbeddingStatsTracker.h

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,7 @@ class EmbeddingStatsTracker {
128128
input_data_type(input_dt),
129129
output_data_type(output_dt) {}
130130

131-
// Equality operator for hash map
132-
// Used by the unordered_map to determine if two AccessPatternEntry objects
133-
// represent the same entry
134-
bool operator==(const AccessPatternEntry& other) const {
135-
return rows == other.rows && dims == other.dims &&
136-
batch_size == other.batch_size && bag_size == other.bag_size &&
137-
input_data_type == other.input_data_type &&
138-
output_data_type == other.output_data_type;
139-
}
131+
bool operator==(const AccessPatternEntry&) const = default;
140132

141133
// Generate a string representation for debugging and logging purposes
142134
std::string toString() const {

0 commit comments

Comments
 (0)