From 93bfd7d8d0912fbe2a2b0c945e9673696b7b25b1 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 12 May 2023 22:04:09 +0900 Subject: [PATCH] Small speed up to validating entity ids (#92970) --- homeassistant/helpers/config_validation.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/homeassistant/helpers/config_validation.py b/homeassistant/helpers/config_validation.py index 0f53c9108c8..e0924b928ca 100644 --- a/homeassistant/helpers/config_validation.py +++ b/homeassistant/helpers/config_validation.py @@ -567,6 +567,10 @@ def string(value: Any) -> str: if value is None: raise vol.Invalid("string value is None") + # This is expected to be the most common case, so check it first. + if type(value) is str: # pylint: disable=unidiomatic-typecheck + return value + if isinstance(value, template_helper.ResultWrapper): value = value.render_result