[EMAIL PROTECTED] wrote:

As I've been hacking away today, I've been swapping a load of "" + "" + "" style code over to use StringBuffers. I thought that perhaps there's a potential use of a static method in StringUtils to construct these strings from an array


For a significant performance boost we had to refactor the whole (or a
major part) of the codebase in this manner. So I think a performance
test would be good. How much is the improvement on <delete>?


It's less to do with speed performance and more to do with memory performance. "a" + "b" + "c" creates "a" + "bc" <- intermediate String, and then "abc"

I'd love to do a performance/memory test of some kind, perhaps I'll use the new NetBeans (it's supposed to have a good view of the heap being used). Any suggestions on tools to help evaluate changes would be helpful.

We also have a problem with logging in general where the Strings are concatenated :
log("a" + toFile + " b " + dir + etc, verbosity);

This will produce a lot of temp Strings, send the result to log and crucially, if the verbosity is too low, won't even use it - that's a waste of memory in every sense of the word. I'd like to fix this, the appendMessage method I proposed is only a bandaid for now.

Essentially we don't want to perform any operations, or produce any temporary values if they aren't going to be used, but I can't see a way of doing this without something like

if (verbosity >= Project.MSG_INFO) {
 log(msg + e + msg2);
}

but this is subverting the log method that uses the verbosity internally, and adding conditions to the construction of log messages is not nice.


This does not create a log message - it just concatenates the given
arguments.
Would be something like toString(Object[]) better?

yes the name I chose was horrible (I'm severely lacking creativity today obviously :)

You specify the args-param as "message fragments", so I would name the
paramter 'fragments' ;-)
   public static String toString(final Object[] fragments)

...

that would make more sense yes

mmmh .... alternativly you could overload the Task.log() method...
  Task.log(Object[] messageFragments, int loglevel)

Thanks for the comments
Kev

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to