Hi,
> What is the point of fighting on probably fraction of performance here?
Because it’s just as easy to not have that performance penalty and then their’s
no need to worry about it.
As only one month is displayed at once it would be far better to change the
code to what’s below (not tested) and only check the year and month once.
public function getIndexForSelectedDate():Number
{
var d:Date = _selectedDate;
if (d == null || _days[0].getFullYear() != d.getFullYear() ||
_days[0].getMonth() == d.getMonth()) return -1;
for(var i:int=0; i < _days.length; i++) {
var test:Date = _days[i] as Date;
if (test != null) {
if (test.getDate() == d.getDate())
return i;
}
}
return -1;
}
The _days.length shouldn't be calculated every time around the loop either but
that was raised in another pull request.
Thanks,
Justin