From 712bd8a5e1e2d68dafbd5785da625021873724bc Mon Sep 17 00:00:00 2001 From: Maxim Prokhorov Date: Wed, 22 Jan 2020 01:56:59 +0300 Subject: [PATCH] Buttons: small optimization for vector --- code/espurna/button.ino | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/code/espurna/button.ino b/code/espurna/button.ino index e45b5e11..3bb70e79 100644 --- a/code/espurna/button.ino +++ b/code/espurna/button.ino @@ -159,12 +159,16 @@ void buttonSetup() { #if defined(ITEAD_SONOFF_DUAL) + _buttons.reserve(3); + buttonAdd(GPIO_NONE, BUTTON_PUSHBUTTON, 0, _buttonRelay(0)); buttonAdd(GPIO_NONE, BUTTON_PUSHBUTTON, 0, _buttonRelay(1)); buttonAdd(GPIO_NONE, BUTTON_PUSHBUTTON, 0, _buttonRelay(2)); #elif defined(FOXEL_LIGHTFOX_DUAL) + _buttons.reserve(4); + const auto actions = _buttonConstructActions( BUTTON_MODE_NONE, BUTTON_MODE_TOGGLE, BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE, BUTTON_MODE_NONE @@ -208,6 +212,8 @@ void buttonSetup() { ++buttons; #endif + _buttons.reserve(buttons); + // TODO: load based on index button_t::DebounceDelay = getSetting("btnDebounce", BUTTON_DEBOUNCE_DELAY); button_t::DblclickDelay = getSetting("btnDelay", BUTTON_DBLCLICK_DELAY);