One thing that is quite surprising, given this behavior, is that the _columns var is private and not mx_internal or protected.
It makes it very difficult when subclassing a grid to write an effecient component if every access a columns causes the array to be cloned. I have decided to override the setter for columns and also listen for the headerShift event and then get a clone of the columns and store it in a var so the rest of the code can access that cloned copy instead of forcing the duplication each time but it seems a really odd thing to have to do. --- In [email protected], "reflexactions" <[EMAIL PROTECTED]> wrote: > > Ok good to know, > > "cache the set from the DG " > Yeah thats what I thought as well... > > Performance hit maybe not be bad by itself but I did see some code > that looped the over the columns array: > > for(.. columns.length ...)columns[i] > > So on every loop you duplicate the array once for the length check > and once again for the access and on a 20+column array that starts to > add up... > > tks > --- In [email protected], "Alex Harui" <aharui@> > wrote: > > > > Yeah, you're making a copy every time. Shouldn't be a major > performance > > hit as it doesn't clone the column objects, it just makes a new > array of > > references to them. > > > > > > > > If you have to get at them often, you might want to keep a > reference to > > the set you passed in, or cache the set from the DG unless you > think it > > is going to change often. > > > > > > > > ________________________________ > > > > From: [email protected] > > [mailto:[EMAIL PROTECTED] On Behalf Of reflexactions > > Sent: Friday, October 19, 2007 11:10 PM > > To: [email protected] > > Subject: [flexcomponents] DataGrid column access > > > > > > > > I am working on a DataGrid subcomponent and have been accessing the > > columns array frequently, thinking nothing of it I just do > something > > like: > > > > ... columns[i] ... > > > > but then I saw that the columns getter function does a > _columns.slice > > (0). > > > > Is the compiler smart enough to figure out i dont really want to > clone > > the columns array every time I access it or am I really forcing it > to > > copy the array? > > > > tks > > >
