mirror of
https://github.com/esphome/esphome.git
synced 2025-07-28 14:16:40 +00:00
Eliminate bluetooth_proxy guard variable to save 8 bytes RAM (#9343)
This commit is contained in:
parent
206659ddb8
commit
42a1f6922f
@ -58,10 +58,15 @@ bool BluetoothProxy::parse_device(const esp32_ble_tracker::ESPBTDevice &device)
|
|||||||
// 16 advertisements × 80 bytes (worst case) = 1280 bytes out of ~1320 bytes usable payload
|
// 16 advertisements × 80 bytes (worst case) = 1280 bytes out of ~1320 bytes usable payload
|
||||||
// This achieves ~97% WiFi MTU utilization while staying under the limit
|
// This achieves ~97% WiFi MTU utilization while staying under the limit
|
||||||
static constexpr size_t FLUSH_BATCH_SIZE = 16;
|
static constexpr size_t FLUSH_BATCH_SIZE = 16;
|
||||||
static std::vector<api::BluetoothLERawAdvertisement> &get_batch_buffer() {
|
|
||||||
static std::vector<api::BluetoothLERawAdvertisement> batch_buffer;
|
namespace {
|
||||||
return batch_buffer;
|
// Batch buffer in anonymous namespace to avoid guard variable (saves 8 bytes)
|
||||||
}
|
// This is initialized at program startup before any threads
|
||||||
|
// NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
|
||||||
|
std::vector<api::BluetoothLERawAdvertisement> batch_buffer;
|
||||||
|
} // namespace
|
||||||
|
|
||||||
|
static std::vector<api::BluetoothLERawAdvertisement> &get_batch_buffer() { return batch_buffer; }
|
||||||
|
|
||||||
bool BluetoothProxy::parse_devices(const esp32_ble::BLEScanResult *scan_results, size_t count) {
|
bool BluetoothProxy::parse_devices(const esp32_ble::BLEScanResult *scan_results, size_t count) {
|
||||||
if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr || !this->raw_advertisements_)
|
if (!api::global_api_server->is_connected() || this->api_connection_ == nullptr || !this->raw_advertisements_)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user