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

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

@javan javan added the actiontext label Aug 22, 2019

Optimize Action Text's plain text conversion
Fixes that converting deeply nested elements could exceed the stack level.

@javan javan force-pushed the javan: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("")

This comment has been minimized.

Copy link
@kamipo

kamipo Aug 22, 2019

Member

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

This comment has been minimized.

Copy link
@javan

javan Aug 22, 2019

Author Member

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

buildkite/rails Build #63247 passed (6 minutes, 33 seconds)
Details
codeclimate All good!
Details

@javan javan deleted the javan: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
3 participants
You can’t perform that action at this time.