Hi there, Can i simplify this snippet ? :
to this one :
private void getTimeFactorPerAction(){
for (int i = 0; i < this.actions.length; i++) {
//get the action duration.
final double actionLength = this.actions[i].getLength();
if (actionLength > 0 && getLength() > 0) {
//get the timeFactor(timeScale) of the inscribed action with respect to its parent Action.
this.timeFactor[i] = actionLength / getLength();
}else{
//assign a default value if durations are negative
this.timeFactor[i] = 1;
}
}
}
Would that be cleaner or would it likely lead to side effects ?
Why i did this :
Since timeFactor
is a fraction of inscribedActionLength / sampleAction, then mathematically if they are equal then the result is one, no need to hardly code it, otherwise if the duration is -ve we may skip calculations & hard code it, (but we can also use negative values only if both are negative, anyway the idea of negative duration is silly, it’s better handled.)