Skip to content

Commit

Permalink
Pre-allocate COM vector
Browse files Browse the repository at this point in the history
  • Loading branch information
blazoncek committed Sep 11, 2024
1 parent b431515 commit 5df1a22
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions wled00/bus_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ struct ColorOrderMap {
bool add(uint16_t start, uint16_t len, uint8_t colorOrder);

inline uint8_t count() const { return _mappings.size(); }
inline void reserve(size_t num) { _mappings.reserve(num); }

void reset() {
_mappings.clear();
Expand Down
1 change: 1 addition & 0 deletions wled00/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ bool deserializeConfig(JsonObject doc, bool fromFS) {
// read color order map configuration
JsonArray hw_com = hw[F("com")];
if (!hw_com.isNull()) {
BusManager::getColorOrderMap().reserve(std::min(hw_com.size(), (size_t)WLED_MAX_COLOR_ORDER_MAPPINGS));
for (JsonObject entry : hw_com) {
uint16_t start = entry["start"] | 0;
uint16_t len = entry["len"] | 0;
Expand Down
1 change: 1 addition & 0 deletions wled00/set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage)
}
//doInitBusses = busesChanged; // we will do that below to ensure all input data is processed

// we will not bother with pre-allocating ColorOrderMappings vector
for (int s = 0; s < WLED_MAX_COLOR_ORDER_MAPPINGS; s++) {
int offset = s < 10 ? 48 : 55;
char xs[4] = "XS"; xs[2] = offset+s; xs[3] = 0; //start LED
Expand Down

0 comments on commit 5df1a22

Please sign in to comment.