Hi,

> I have a small performance suggestion for the class in this patch.
> 
> > @@ -131,7 +141,7 @@
> >      public void mouseDragged(MouseEvent e) 
> >      {
> >        curr = new Point(e.getX(), e.getY());
> > -      updateSelection();      
> > +      updateSelection(e.isControlDown());      
> >      }
> >      public void mouseEntered(MouseEvent e) 
> >      {
> > @@ -146,7 +156,8 @@
> >      {
> >        begin = new Point(e.getX(), e.getY());
> >        curr = new Point(e.getX(), e.getY());
> > -      updateSelection();
> > +      updateSelection(e.isControlDown());
> > +      
> The Point instantiations will IMHO happen very often. I would change the
>  code in a way that 'curr' and 'begin' are just updated with the new
> values of 'e' instead of creating a new instance every time.

Yeah, this is becoming a real problem in Swing. The same holds true for
Rectangle and Dimension instances. More of them should be cached and
reused.

Maybe we should add a little pool implementation, so we avoid having
Point/Rectangle/Dimension cache fields all over the Swing classes.?
Instead of writing 'new Point(x, y)' this would change to
'Pool.getPoint(x, y)' or something like this. Any comments?

/Roman




_______________________________________________
Classpath-patches mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath-patches

Reply via email to