mirror of
https://github.com/esphome/esphome.git
synced 2025-11-01 07:31:51 +00:00
likely
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
#include "esphome/core/component.h"
|
||||
#include "esphome/core/helpers.h"
|
||||
#include "esphome/core/log.h"
|
||||
#include "esphome/core/macros.h"
|
||||
#include "esphome/core/string_ref.h"
|
||||
|
||||
#include <cassert>
|
||||
@@ -14,13 +15,6 @@
|
||||
#define HAS_PROTO_MESSAGE_DUMP
|
||||
#endif
|
||||
|
||||
// Branch prediction hints for hot paths
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define ESPHOME_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#else
|
||||
#define ESPHOME_LIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
namespace esphome::api {
|
||||
|
||||
// Protocol Buffer wire type constants
|
||||
|
||||
@@ -3,6 +3,15 @@
|
||||
// Helper macro to define a version code, whose value can be compared against other version codes.
|
||||
#define VERSION_CODE(major, minor, patch) ((major) << 16 | (minor) << 8 | (patch))
|
||||
|
||||
// Branch prediction hints for performance-critical paths
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define ESPHOME_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define ESPHOME_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#else
|
||||
#define ESPHOME_LIKELY(x) (x)
|
||||
#define ESPHOME_UNLIKELY(x) (x)
|
||||
#endif
|
||||
|
||||
#ifdef USE_ARDUINO
|
||||
#include <Arduino.h>
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user