4 ms·
Well, it's a C macro in Apache Thrift code base [1] #ifdef __GNUC__ #define TDB_LIKELY(val) (__builtin_expect((val), 1)) #define TDB_UNLIKELY(val) (__builtin
by anhldbk 7y ago
Well, it's a C macro in Apache Thrift code base [1]
#ifdef __GNUC__
#define TDB_LIKELY(val) (__builtin_expect((val), 1))
#define TDB_UNLIKELY(val) (__builtin_expect((val), 0))
#else
#define TDB_LIKELY(val) (val)
#define TDB_UNLIKELY(val) (val)
#endif
This code is beautiful when it deal with CPU cache-line effects to speed up your program.
[1] https://github.com/apache/thrift/blob/647501693bd14256df8839c13cb03659bdee4202/lib/cpp/src/thrift/transport/TBufferTransports.h#L32-L33 https://github.com/apache/thrift/blob/647501693bd14256df8839...
- tomtomtom777 7y agoYou seem to be referring to the arguably beautiful effect of code. Are you seriously praising this monstrosity of preprocessor macros, integers used as magic booleans and compiler specific builtins as beautiful code??