Optimize the JEditBuffer.bufferListener a bit.
I think we don't need to optimize anything "a bit". Only significant optimizations with sufficient justification may be considered.
I'm not sure this is really an optimization. In general, replacing Vector with ArrayList will improve performance since all the methods in Vector are synchronized, but then wrapping each access to the ArrayList with a synchronized block eliminates that performance gain. Perhaps a slightly better optimization would be to replace the Vector with a Set of some sort, that might help with memory management by reducing the possibility of duplicates in the Vector. With out some profiling, I'm not sure it's worth doing.
I now did some measurement and daleanson is right. I hoped that taking the lock only once would be faster than taking it each time again for each entry in the bufferListener List. But as my measurements show this is not true. my code is actually slower, because of the Iterator usage in the for-each-loop. So I learned: I must measure every change, you just can't really on feelings in IT :-)
sorry, for the noise.
Log in to post a comment.