[ https://issues.apache.org/jira/browse/MNG-7899?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17776228#comment-17776228 ]
ASF GitHub Bot commented on MNG-7899: ------------------------------------- sebastien-doyon commented on PR #1269: URL: https://github.com/apache/maven/pull/1269#issuecomment-1766473890 > @sebastien-doyon unit tests seem broken. @gnodet yes, I am trying to find the problem, but without access to the surefire report files, it is hard to find the problem. Do you have access or know how to get access to the target directory of a build in github? That would help debug. > Also and fwiw, this looks like all this work may be broken if we somehow integrate https://github.com/apache/maven/pull/1279... we may want to investigate on that branch then... I think the PR [1279](https://github.com/apache/maven/pull/1279) is complementary with this PR. The only change in the 1279 PR that would be needed is to add back the `MessageBuilder builder(StringBuilder stringBuilder)` method to `api/maven-api-core/src/main/java/org/apache/maven/api/services/MessageBuilderFactory.java` and `maven-core/src/main/java/org/apache/maven/internal/impl/DefaultMessageBuilderFactory.java` classes. > Also, https://github.com/apache/maven/pull/1268, https://github.com/apache/maven/pull/1269 and https://github.com/apache/maven/pull/1270 really look related to the same goal, I.e. optimize the logging, so I think they should be merged in order to have a better understand of the benefits (even if they could be 3 different commits). If you think, I was trying to separate unrelated changes so the obvious ones could be merged while those with problems or comments could be worked out separately, like this one. Tell me if you really prefer me to merge in on PR. > Various memory usage improvements > --------------------------------- > > Key: MNG-7899 > URL: https://issues.apache.org/jira/browse/MNG-7899 > Project: Maven > Issue Type: Improvement > Components: Design, Patterns & Best Practices, Embedding, > General, Logging > Affects Versions: 4.0.0-alpha-2 > Reporter: sebastien > Priority: Major > > Some optimisations can be applied to the code to reduce the use of temporary > objects. > Typical improvements identified are: > * reduce scope of temporary objects creation to avoid creating when not > needed. Example : > {code:java} > public String toString() { > StringBuilder sb = new StringBuilder(512); > if (isEmpty()) { > return "empty"; > } > for (MetadataGraphVertex v : vertices) { > .....{code} > can be replaced by > {code:java} > public String toString() { > if (isEmpty()) { > return "empty"; > } > StringBuilder sb = new StringBuilder(512); > for (MetadataGraphVertex v : vertices) { > .....{code} > * Reuse StringBuilder objects in loops by setting its length to zero > * Use the StringBuilder.append() with index to avoid String.substring(). > Example: > > {code:java} > int idx = resourceName.lastIndexOf('/'); > buffer.append(idx < 0 ? resourceName : resourceName.substring(idx + 1)); > {code} > can be replaced by > > {code:java} > int idx = resourceName.lastIndexOf('/'); > if (idx < 0) { > buffer.append(resourceName); > } else { > buffer.append(resourceName, idx + 1, resourceName.length()); > } {code} > > > * Replace dynamic string creation static constants when possible > * Avoid creating temporary strings with + operator when the final > destination can be used instead, like PrintStream.print() method > * Avoir using StringBuilder.append() method and util method MessageUtils.a() > when the final destination can be used instead, like PrintStream.print() > method > -- This message was sent by Atlassian Jira (v8.20.10#820010)