From fe395ac41d18949d8acf26ea012dabdffad5d1d5 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 26 Mar 2026 13:10:04 -1000 Subject: [PATCH] Use plain vector compat members, add custom modes benchmark MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The owned vectors add 48 bytes to ClimateTraits copies — this is the cost of backward compat and will be removed in 2026.11.0. Add ClimatePublish_WithCustomModes benchmark to show the improvement for climate devices that use custom fan modes and presets (the case that previously heap-allocated on every publish). --- tests/benchmarks/components/climate/bench_climate.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/benchmarks/components/climate/bench_climate.cpp b/tests/benchmarks/components/climate/bench_climate.cpp index 316a72b2b6..0416b6daa3 100644 --- a/tests/benchmarks/components/climate/bench_climate.cpp +++ b/tests/benchmarks/components/climate/bench_climate.cpp @@ -54,6 +54,9 @@ static void setup_hvac_climate(BenchClimate &climate) { climate.traits_.set_visual_target_temperature_step(0.5f); climate.traits_.set_visual_current_temperature_step(0.1f); climate.traits_.add_feature_flags(climate::CLIMATE_SUPPORTS_CURRENT_TEMPERATURE | climate::CLIMATE_SUPPORTS_ACTION); + // Custom modes use the new API — stored on Climate entity, zero-copy in get_traits() + climate.set_supported_custom_fan_modes({"Turbo", "Silent", "Eco"}); + climate.set_supported_custom_presets({"My Preset", "Night Mode"}); } // --- Climate::publish_state() with temperature update ---