Menu

#435 JEditBuffer.bufferListener use ArrayList and for-each-loops

closed-rejected
None
5
2012-06-17
2012-06-16
No

Optimize the JEditBuffer.bufferListener a bit.

Discussion

  • Jarek Czekalski

    Jarek Czekalski - 2012-06-16
    • status: open --> pending-rejected
     
  • Jarek Czekalski

    Jarek Czekalski - 2012-06-16

    I think we don't need to optimize anything "a bit". Only significant optimizations with sufficient justification may be considered.

     
  • Dale Anson

    Dale Anson - 2012-06-17

    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.

     
  • Thomas Meyer

    Thomas Meyer - 2012-06-17
    • status: pending-rejected --> open-rejected
     
  • Thomas Meyer

    Thomas Meyer - 2012-06-17

    Hi,

    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.

     
  • Jarek Czekalski

    Jarek Czekalski - 2012-06-17
    • assigned_to: nobody --> jarekczek
    • status: open-rejected --> closed-rejected
     

Log in to post a comment.