Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize Action Text's plain text conversion #37016

Merged
merged 1 commit into from Aug 22, 2019

Conversation

@javan
Copy link
Member

@javan javan commented Aug 22, 2019

Fixes that converting deeply nested elements could exceed the stack level, as seen in the added test failing before the optimization:

.....................................E

Error:
ActionText::PlainTextConversionTest#test_deeply_nested_tags_are_converted:
SystemStackError: stack level too deep

See also: https://twitter.com/javan/status/1164545630079016965

Fixes that converting deeply nested elements could exceed the stack level.
@javan javan force-pushed the actiontext/optimize-plain-text-conversion branch from 64a289b to 55a5aac Aug 22, 2019
kaspth
kaspth approved these changes Aug 22, 2019
node.children.each_with_index do |child, index|
texts << plain_text_for_node(child, index)
end
texts.join("")
Copy link
Member

@kamipo kamipo Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is not compact necessary? (plain_text_for_node will not return nil?)

Copy link
Member Author

@javan javan Aug 22, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't appear to be necessary, and I don't see nil being returned anywhere. I don't think it's an issue either way since nils would disappear as empty strings when the array is joined:

>> [ "a", nil, nil, "b", "", nil, "c" ].join("")
=> "abc"

@javan javan merged commit 58f1eca into rails:master Aug 22, 2019
2 checks passed
@javan javan deleted the actiontext/optimize-plain-text-conversion branch Aug 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants