You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by alexhenrie <gi...@git.apache.org> on 2015/11/20 19:22:17 UTC

[GitHub] maven pull request: String handling issues identified by PMD

GitHub user alexhenrie opened a pull request:

    https://github.com/apache/maven/pull/72

    String handling issues identified by PMD

    The code linting tool [PMD](http://pmd.sourceforge.net/pmd-5.2.0/) identified numerous places where Maven's string handling is inefficient. I've prepared a set of patches that should help speed things up.
    
    The command I used was `pmd -d . -R java-strings`

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/alexhenrie/maven master

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/maven/pull/72.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #72
    
----
commit 14f3e7f8cae1dc74b616a52f32ac54762fd640ed
Author: Alex Henrie <al...@gmail.com>
Date:   2015-11-20T05:23:08Z

    Prefer StringBuilder.append(char) to StringBuilder.append(String)
    
    http://pmd.sourceforge.net/pmd-5.2.0/pmd-java/rules/java/strings.html#AppendCharacterWithChar

commit a78a98aa8eb38bd9d239eadcf72bb7fde04463e1
Author: Alex Henrie <al...@gmail.com>
Date:   2015-11-20T05:23:09Z

    Prefer String.indexOf(char) to String.indexOf(String)
    
    http://pmd.sourceforge.net/pmd-5.2.0/pmd-java/rules/java/strings.html#UseIndexOfChar

commit 678103e544bbb28c8afd2a5b7117cc33897cac05
Author: Alex Henrie <al...@gmail.com>
Date:   2015-11-20T05:23:09Z

    Combine string literals instead of calling String.append twice
    
    http://pmd.sourceforge.net/pmd-5.2.0/pmd-java/rules/java/strings.html#ConsecutiveLiteralAppends

commit 30f0c2a69a4c447dc2562102dbb324a35f5e77e7
Author: Alex Henrie <al...@gmail.com>
Date:   2015-11-20T05:23:10Z

    Construct StringBuffers with enough space to begin with
    
    http://pmd.sourceforge.net/pmd-5.2.0/pmd-java/rules/java/strings.html#InsufficientStringBufferDeclaration

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by jvanzyl <gi...@git.apache.org>.
Github user jvanzyl commented on the pull request:

    https://github.com/apache/maven/pull/72#issuecomment-158483928
  
    I have some code that touches a lot of this so I'd like to apply that first. Also what's the performance difference you observe?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by Tibor17 <gi...@git.apache.org>.
Github user Tibor17 commented on the pull request:

    https://github.com/apache/maven/pull/72#issuecomment-158668300
  
    Nowadays execution time of array allocation is logarithmic function(array.length).
    One way or another since of Java 6 the the objects are allocated in the stack instead of in main memory. This did speed up the entire VM in Java 6 (u45). So regarding array size with length 512 in StringBuilder and 3GHz CPU, the allocation take much less than 150 nano seconds because the allocation is logarithmic maybe 50 nanos or so.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by alexhenrie <gi...@git.apache.org>.
Github user alexhenrie commented on the pull request:

    https://github.com/apache/maven/pull/72#issuecomment-181991785
  
    OK, thanks!


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by ChristianSchulte <gi...@git.apache.org>.
Github user ChristianSchulte commented on the pull request:

    https://github.com/apache/maven/pull/72#issuecomment-181984267
  
    This has been committed. See MNG-5934. Please close this pull request manually.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by alexhenrie <gi...@git.apache.org>.
Github user alexhenrie commented on the pull request:

    https://github.com/apache/maven/pull/72#issuecomment-158709078
  
    @jvanzyl I can wait until you've finished your other changes, that's no problem. I haven't been able to measure the performance improvement because Maven's execution time is so variable. However, if you search for more information about these optimizations, you will find people explaining that they are indeed worthwhile.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


[GitHub] maven pull request: String handling issues identified by PMD

Posted by alexhenrie <gi...@git.apache.org>.
Github user alexhenrie closed the pull request at:

    https://github.com/apache/maven/pull/72


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org