瀏覽代碼

Replace with last & pop instead of new array.

tschw 10 年之前
父節點
當前提交
4be9ffc4ca
共有 1 個文件被更改,包括 3 次插入15 次删除
  1. 3 15
      src/renderers/WebGLRenderer.js

+ 3 - 15
src/renderers/WebGLRenderer.js

@@ -731,23 +731,11 @@ THREE.WebGLRenderer = function ( parameters ) {
 
 		if ( deleteProgram === true ) {
 
-			// avoid using array.splice, this is costlier than creating new array from scratch
+			// avoid using array.splice, instead replace with last and pop
 
-			var newPrograms = [];
+			_programs[ i ] = _programs[ il - 1 ];
+			_programs.pop();
 
-			for ( i = 0, il = _programs.length; i < il; i ++ ) {
-
-				programInfo = _programs[ i ];
-
-				if ( programInfo.program !== program ) {
-
-					newPrograms.push( programInfo );
-
-				}
-
-			}
-
-			_programs = newPrograms;
 
 			_gl.deleteProgram( program );