Skip to content

Commit

Permalink
Skip instantiation of VarData unless data was actually merged
Browse files Browse the repository at this point in the history
  • Loading branch information
masenf committed Aug 21, 2024
1 parent ffc05fb commit 62fd68f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions reflex/vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,14 @@ def merge(cls, *others: ImmutableVarData | VarData | None) -> VarData | None:
var_data.interpolations if isinstance(var_data, VarData) else []
)

return (
cls(
if state or _imports or hooks or interpolations:
return cls(
state=state,
imports=_imports,
hooks=hooks,
interpolations=interpolations,
)
or None
)
return None

def __bool__(self) -> bool:
"""Check if the var data is non-empty.
Expand Down Expand Up @@ -301,14 +300,13 @@ def merge(
else {k: None for k in var_data.hooks}
)

return (
ImmutableVarData(
if state or _imports or hooks:
return ImmutableVarData(
state=state,
imports=_imports,
hooks=hooks,
)
or None
)
return None

def __bool__(self) -> bool:
"""Check if the var data is non-empty.
Expand Down

0 comments on commit 62fd68f

Please sign in to comment.