mirror of
https://github.com/esphome/esphome.git
synced 2025-11-17 15:26:01 +00:00
likely
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
#include "esphome/core/component.h"
|
#include "esphome/core/component.h"
|
||||||
#include "esphome/core/helpers.h"
|
#include "esphome/core/helpers.h"
|
||||||
#include "esphome/core/log.h"
|
#include "esphome/core/log.h"
|
||||||
|
#include "esphome/core/macros.h"
|
||||||
#include "esphome/core/string_ref.h"
|
#include "esphome/core/string_ref.h"
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
@@ -14,13 +15,6 @@
|
|||||||
#define HAS_PROTO_MESSAGE_DUMP
|
#define HAS_PROTO_MESSAGE_DUMP
|
||||||
#endif
|
#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 {
|
namespace esphome::api {
|
||||||
|
|
||||||
// Protocol Buffer wire type constants
|
// 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.
|
// 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))
|
#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
|
#ifdef USE_ARDUINO
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user