classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] FYI: JTable changeSelection and multiple selection impl


From: Roman Kennke
Subject: Re: [cp-patches] FYI: JTable changeSelection and multiple selection implementation
Date: Fri, 01 Jul 2005 09:24:20 +0200

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






reply via email to

[Prev in Thread] Current Thread [Next in Thread]