Skip to content

Use new RubyStringBuilder.str api to create inspected string for Exception#5927

Merged
kares merged 2 commits intojruby:masterfrom
jlahtinen:fix_5923_exception_inspect_in_wrong_encoding
Oct 21, 2019
Merged

Use new RubyStringBuilder.str api to create inspected string for Exception#5927
kares merged 2 commits intojruby:masterfrom
jlahtinen:fix_5923_exception_inspect_in_wrong_encoding

Conversation

@jlahtinen
Copy link
Contributor

pull request fix for #5923

new StringBuilder(2 + rubyClass.length() + 2 + exception.size() + 1).
append("#<").append(rubyClass).append(": ").append(exception.getByteList()).append('>')
);
String exceptionStartStr = new StringBuilder(2 + rubyClass.length() + 2).append("#<").append(rubyClass).append(": ").toString();
Copy link
Member

@kares kares Oct 21, 2019

Choose a reason for hiding this comment

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

you should nuke the explicit StringBuilder here - it's not needed (you could just + if the API is not enough)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think nuking is done now.

Copy link
Member

Choose a reason for hiding this comment

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

the last round-trip (Ruby -> Java -> Ruby string) is redundant, but we can fix that later ...

Compiler makes it as good as it can be and code is easier to read.
@kares kares merged commit 131bcdf into jruby:master Oct 21, 2019
@kares kares added this to the JRuby 9.2.9.0 milestone Oct 21, 2019
@enebo
Copy link
Member

enebo commented Oct 21, 2019

Super cool. I may change the signature to be ruby,string,irubyobject,string,irubyobject,string but thanks for this work. We really appreciate it!

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.

3 participants