Skip to content

Remove redundant nil check for child_diff#4293

Open
preciz wants to merge 1 commit into
phoenixframework:mainfrom
preciz:remove-redundant-nil-check
Open

Remove redundant nil check for child_diff#4293
preciz wants to merge 1 commit into
phoenixframework:mainfrom
preciz:remove-redundant-nil-check

Conversation

@preciz

@preciz preciz commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

child_diff is always a map.

child_diff is always a map.
@SteffenDE

Copy link
Copy Markdown
Member

I don't think it is immediately obvious why it can't be nil, can you elaborate?

@preciz

preciz commented Jun 14, 2026

Copy link
Copy Markdown
Contributor Author

Here traverse_dynamic is called with 6 arguments:

{_counter, child_diff, child_prints, pending, components, template} =
traverse_dynamic(
render.(vars_changed, changed?),
child_prints,
pending,
components,
template,
changed?
)

Because of this diff is initialized to %{} here:

defp traverse_dynamic(dynamic, children, pending, components, template, changed?) do
traverse_dynamic(dynamic, 0, %{}, children, pending, components, template, changed?)
end

And then it is never set to nil if I follow the code correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants