Browse Source

Skip the last keyframe operation of KeyframeTrackPrototype.optimize() if times.length <= 1 (#9691)

Takahiro 9 years ago
parent
commit
efad557d23
1 changed files with 8 additions and 4 deletions
  1. 8 4
      src/animation/KeyframeTrackPrototype.js

+ 8 - 4
src/animation/KeyframeTrackPrototype.js

@@ -336,13 +336,17 @@ KeyframeTrackPrototype = {
 
 		// flush last keyframe (compaction looks ahead)
 
-		times[ writeIndex ] = times[ lastIndex ];
+		if ( lastIndex > 0 ) {
 
-		for ( var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j )
+			times[ writeIndex ] = times[ lastIndex ];
 
-			values[ writeOffset + j ] = values[ readOffset + j ];
+			for ( var readOffset = lastIndex * stride, writeOffset = writeIndex * stride, j = 0; j !== stride; ++ j )
 
-		++ writeIndex;
+				values[ writeOffset + j ] = values[ readOffset + j ];
+
+			++ writeIndex;
+
+		}
 
 		if ( writeIndex !== times.length ) {