在update中調(diào)用addBalls函數(shù)時(shí),if使用嵌套的方式會(huì)使性能更好嗎?
像這樣
if(curSeconds!==nextSeconds){
addBalls(MARGIN_LEFT+46.5*square, MARGIN_TOP, nextSeconds%10);
if(parseInt(curSeconds/10)!==parseInt(nextSeconds/10)){
addBalls(MARGIN_LEFT+39*square, MARGIN_TOP, parseInt(nextSeconds/10));
if(curMinutes%10!==nextMinutes%10){
addBalls(MARGIN_LEFT+27*square, MARGIN_TOP, curMinutes%10);
if(parseInt(curMinutes/10)!==parseInt(nextMinutes/10)){
addBalls(MARGIN_LEFT+19.5*square, MARGIN_TOP, parseInt(curMinutes/10));
if(curHours%10!==nextHours%10){
addBalls(MARGIN_LEFT+7.5*square, MARGIN_TOP, curHours%10);
if(parseInt(curHours/10)!==parseInt(nextHours/10)){
addBalls(MARGIN_LEFT, MARGIN_TOP, parseInt(curHours/10));
}
}
}
}
}
curTimeSeconds=nextTimeSeconds;
}
2016-12-07