1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-23 20:23:50 +01:00

Reduce web_server RAM usage by 96 bytes with conditional sorting compilation (#9227)

This commit is contained in:
J. Nick Koston
2025-06-29 18:47:20 -05:00
committed by GitHub
parent e907050a17
commit 687cb1cd2b
5 changed files with 46 additions and 120 deletions

View File

@@ -46,6 +46,7 @@ struct UrlMatch {
bool valid; ///< Whether this match is valid
};
#ifdef USE_WEBSERVER_SORTING
struct SortingComponents {
float weight;
uint64_t group_id;
@@ -55,6 +56,7 @@ struct SortingGroup {
std::string name;
float weight;
};
#endif
enum JsonDetail { DETAIL_ALL, DETAIL_STATE };
@@ -474,14 +476,18 @@ class WebServer : public Controller, public Component, public AsyncWebHandler {
/// This web handle is not trivial.
bool isRequestHandlerTrivial() const override; // NOLINT(readability-identifier-naming)
#ifdef USE_WEBSERVER_SORTING
void add_entity_config(EntityBase *entity, float weight, uint64_t group);
void add_sorting_group(uint64_t group_id, const std::string &group_name, float weight);
std::map<EntityBase *, SortingComponents> sorting_entitys_;
std::map<uint64_t, SortingGroup> sorting_groups_;
#endif
bool include_internal_{false};
protected:
void add_sorting_info_(JsonObject &root, EntityBase *entity);
void schedule_(std::function<void()> &&f);
web_server_base::WebServerBase *base_;
#ifdef USE_ARDUINO