mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	tweak
This commit is contained in:
		| @@ -62,8 +62,7 @@ static void validate_static_string(const char *name) { | ||||
| void HOT Scheduler::set_timer_common_(Component *component, SchedulerItem::Type type, bool is_static_string, | ||||
|                                       const void *name_ptr, uint32_t delay, std::function<void()> func) { | ||||
|   // Get the name as const char* | ||||
|   const char *name_cstr = | ||||
|       is_static_string ? static_cast<const char *>(name_ptr) : static_cast<const std::string *>(name_ptr)->c_str(); | ||||
|   const char *name_cstr = this->get_name_cstr_(is_static_string, name_ptr); | ||||
|  | ||||
|   if (delay == SCHEDULER_DONT_RUN) { | ||||
|     // Still need to cancel existing timer if name is not empty | ||||
| @@ -418,8 +417,7 @@ void HOT Scheduler::execute_item_(SchedulerItem *item) { | ||||
| bool HOT Scheduler::cancel_item_(Component *component, bool is_static_string, const void *name_ptr, | ||||
|                                  SchedulerItem::Type type) { | ||||
|   // Get the name as const char* | ||||
|   const char *name_cstr = | ||||
|       is_static_string ? static_cast<const char *>(name_ptr) : static_cast<const std::string *>(name_ptr)->c_str(); | ||||
|   const char *name_cstr = this->get_name_cstr_(is_static_string, name_ptr); | ||||
|  | ||||
|   // Handle null or empty names | ||||
|   if (name_cstr == nullptr) | ||||
|   | ||||
| @@ -145,6 +145,11 @@ class Scheduler { | ||||
|   // Helper to cancel items by name - must be called with lock held | ||||
|   bool cancel_item_locked_(Component *component, const char *name, SchedulerItem::Type type, bool defer_only); | ||||
|  | ||||
|   // Helper to extract name as const char* from either static string or std::string | ||||
|   inline const char *get_name_cstr_(bool is_static_string, const void *name_ptr) { | ||||
|     return is_static_string ? static_cast<const char *>(name_ptr) : static_cast<const std::string *>(name_ptr)->c_str(); | ||||
|   } | ||||
|  | ||||
|   // Common implementation for cancel operations | ||||
|   bool cancel_item_(Component *component, bool is_static_string, const void *name_ptr, SchedulerItem::Type type); | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user