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
Contributor

@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 Compare August 22, 2019 20:25
node.children.each_with_index do |child, index|
texts << plain_text_for_node(child, index)
end
texts.join("")
Copy link
Member

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
Contributor Author

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
@javan javan deleted the actiontext/optimize-plain-text-conversion branch August 22, 2019 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants