#35 decreasing the number of temporary Strings

closed-rejected
nobody
COM Events (10)
5
2009-06-06
2008-12-11
Jerome
No

In the [com.jacob.activeX.ActiveXComponent].logCallbackEvent method
the attached patch avoid:

1. empty string assignment even if nothing is printed in System.out (or ActiveXComponent.shouldLogEvents is false)

2. many temporary String creation in the arguments loop by using a StringBuilder.

Discussion

  • Jerome
    Jerome
    2008-12-11

    [com.jacob.activeX.ActiveXComponent].logCallbackEvent

     
  • clay_shooter
    clay_shooter
    2009-06-06

    • status: open --> closed-rejected
     
  • clay_shooter
    clay_shooter
    2009-06-06

    The first assignment has no ongoing cost. Strings are immutable and the "" string will be created only one time. The variable will always be assigned a reference to that string that is only created one time. This should be essentially free.

    I believe that the compiler converts string concatination to string builder calls under the hood in JDK 1.5 and later.