Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#114 [Patch] StringConstantFolder

open
None
7
2011-06-16
2011-06-16
No

The patch replaces calls to String.length() with the result (if the string is known). Also replaces StringBuffer.append(String).append(String) construction where both strings are known.

There should probably also be a check for StringBuilder, but the optimization was only written with Java ME in mind.

Discussion

  • Eric Lafortune
    Eric Lafortune
    2011-06-16

    • assigned_to: nobody --> lafortune
    • priority: 5 --> 7
     
  • Eric Lafortune
    Eric Lafortune
    2011-06-19

    I had so far avoided optimizations for specific runtime classes, but I guess these String-related classes are sufficiently common. I've now added optimizations for String#length and StringBuffer/StringBuilder init/append with constant Strings/booleans/chars/ints/etc. The implementation as pattern matching peephole optimizations is more compact and somewhat more readable. Coming up in ProGuard 4.7 beta1.

     
  • I didn't see how to do it with a pattern matcher, but I'm looking forward to the next version.