Avoid compiling entity service schema when passed defaults (#112099)
* Avoid compiling entity service schema when passed defaults * dry
This commit is contained in:
parent
0a462071c8
commit
da6eca7b68
1 changed files with 16 additions and 3 deletions
|
@ -1235,9 +1235,7 @@ TARGET_SERVICE_FIELDS = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
def make_entity_service_schema(
|
def _make_entity_service_schema(schema: dict, extra: int) -> vol.Schema:
|
||||||
schema: dict, *, extra: int = vol.PREVENT_EXTRA
|
|
||||||
) -> vol.Schema:
|
|
||||||
"""Create an entity service schema."""
|
"""Create an entity service schema."""
|
||||||
return vol.Schema(
|
return vol.Schema(
|
||||||
vol.All(
|
vol.All(
|
||||||
|
@ -1255,6 +1253,21 @@ def make_entity_service_schema(
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
BASE_ENTITY_SCHEMA = _make_entity_service_schema({}, vol.PREVENT_EXTRA)
|
||||||
|
|
||||||
|
|
||||||
|
def make_entity_service_schema(
|
||||||
|
schema: dict, *, extra: int = vol.PREVENT_EXTRA
|
||||||
|
) -> vol.Schema:
|
||||||
|
"""Create an entity service schema."""
|
||||||
|
if not schema and extra == vol.PREVENT_EXTRA:
|
||||||
|
# If the schema is empty and we don't allow extra keys, we can return
|
||||||
|
# the base schema and avoid compiling a new schema which is the case
|
||||||
|
# for ~50% of services.
|
||||||
|
return BASE_ENTITY_SCHEMA
|
||||||
|
return _make_entity_service_schema(schema, extra)
|
||||||
|
|
||||||
|
|
||||||
SCRIPT_CONVERSATION_RESPONSE_SCHEMA = vol.Any(template, None)
|
SCRIPT_CONVERSATION_RESPONSE_SCHEMA = vol.Any(template, None)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue