Skip to content

Conversation

@kamilkrzywanski
Copy link
Contributor

Part 1 from #3272

@BartvHelvert
Copy link
Member

I am not sure whether we should merge this, there are cases where this change could negatively affect the performance. Statics are initialized when the class gets instantiated so it might be the case that we compile a regex, and then never use it.

public void appendTo(@NotNull StringBuilder builder) {
builder.append(StringUtil.escapeXmlEntities(myContent).replaceAll("\n", "<br/>"));
builder.append(
NEWLINE_PATTERN.matcher(StringUtil.escapeXmlEntities(myContent))
Copy link
Member

Choose a reason for hiding this comment

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

Probably, just replacing this call with replace would be better. Starting from JDK 9 the replace method doesn't use Regex anymore and should be faster for regular string literal replacements. It's not a clear case though, this module has its language level set to 8, so for JDK 8 clients of this code, it will run slower than the pre-compiled variant.

@kamilkrzywanski
Copy link
Contributor Author

@BartvHelvert Ok, closing then

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