feathersui / feathersui-starling

User interface components for Starling Framework and Adobe AIR
https://feathersui.com/learn/as3-starling/
Other
914 stars 386 forks source link

DataGrid.as: Fixed potential index out of range error in validateCustomColumnSizes() #1816

Closed esidegallery closed 2 years ago

esidegallery commented 2 years ago

The error occurs when fixed columns are skipped.

joshtynjala commented 2 years ago

Thanks! Can you make a tweak?

I try to avoid calling push() on arrays because it has a ...rest argument, which allocates a temporary array that eventually needs garbage collection. I would like to keep this code in the form: indices[/* some value here */] = i;, if at all possible.

Maybe with var currentIndex:int = 0; before the loop. Then, like this:

indices[currentIndex] = i;
currentIndex++;
esidegallery commented 2 years ago

Done. Actually I did indices[currentIndex++] = i; (which may not be in your coding convention 🫣) Thanks for the info on push(). I shall avoid it henceforth!

joshtynjala commented 2 years ago

which may not be in your coding convention

Yeah, you're right. I try to be extra careful with the ++ operator. I recall that there's something tricky about when the increment gets applied if there are certain other things happening on the same line. So if I use ++, I always put it on its own line. It's fine. I'll merge and fix it.