groovy

Provide size() on StringBuilder

Details

  • Type: New Feature New Feature
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: None
  • Fix Version/s: 1.5.2
  • Component/s: None
  • Labels:
    None
  • Number of attachments :
    0

Description

GROOVY-920 resulted in size() being implemented for StringBuffer. size() should also be implemented for StringBuilder on JDK1.5+ platforms.

Activity

Hide
Antti Karanta added a comment -

Similarly, leftShift should be added to StringBuilder. Now it is possible to do this w/ StringBuffer:
sb << "foo"
but not w/ StringBuilder.

Show
Antti Karanta added a comment - Similarly, leftShift should be added to StringBuilder. Now it is possible to do this w/ StringBuffer: sb << "foo" but not w/ StringBuilder.
Hide
blackdrag blackdrag added a comment -

the problem is that StringBuilder is not available on 1.4. As long as we want to be compatible with 1.4 we have to be carefull about using classes of 1.5 or later. Even if we are plitting DefaultGroovyMethods in methods for 1.5 and ones for 1.4, we still have the problem, that this would not compile on 1.4 then. We need to find a suitable mechanism for that first. Any suggestions are welcome

Show
blackdrag blackdrag added a comment - the problem is that StringBuilder is not available on 1.4. As long as we want to be compatible with 1.4 we have to be carefull about using classes of 1.5 or later. Even if we are plitting DefaultGroovyMethods in methods for 1.5 and ones for 1.4, we still have the problem, that this would not compile on 1.4 then. We need to find a suitable mechanism for that first. Any suggestions are welcome
Hide
Russel Winder added a comment -

The difficulty here is that not supporting classes such as StringBuilder in JDK 1.5 labels Groovy as a legacy product. People who use JDK 1.5 know that StrigBuilder is for normal use and StringBuffer is used only in multithreaded shared object cases because of the high overhead of synchronization.

The upshot of this is that we need a JDK 1.5 version of Groovy and a JDK 1.4 version of Groovy. Given the amount of String handling in Groovy, using StringBuilder rather than StringBuffer in Groovy would likely make things faster as well. But this is a guess.

In effect we need conditional compilation in Java as is available in C and C++ – this avoids the run-time overhead of making decisions at run time. Using CPP itself is probably not a good move. I don't know if Maven 2 supports this sort of compilation activity.

Show
Russel Winder added a comment - The difficulty here is that not supporting classes such as StringBuilder in JDK 1.5 labels Groovy as a legacy product. People who use JDK 1.5 know that StrigBuilder is for normal use and StringBuffer is used only in multithreaded shared object cases because of the high overhead of synchronization. The upshot of this is that we need a JDK 1.5 version of Groovy and a JDK 1.4 version of Groovy. Given the amount of String handling in Groovy, using StringBuilder rather than StringBuffer in Groovy would likely make things faster as well. But this is a guess. In effect we need conditional compilation in Java as is available in C and C++ – this avoids the run-time overhead of making decisions at run time. Using CPP itself is probably not a good move. I don't know if Maven 2 supports this sort of compilation activity.
Hide
Paul King added a comment -

Added in the new PluginDGM for Java 5+

Show
Paul King added a comment - Added in the new PluginDGM for Java 5+
Hide
Paul King added a comment -

close off release 1.5.4

Show
Paul King added a comment - close off release 1.5.4

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: