Przeglądaj źródła

WaitEvent: prevent array copy each update

trethaller 7 lat temu
rodzic
commit
f9fa332089
1 zmienionych plików z 7 dodań i 4 usunięć
  1. 7 4
      hxd/WaitEvent.hx

+ 7 - 4
hxd/WaitEvent.hx

@@ -46,10 +46,13 @@ class WaitEvent {
 	}
 
 	public function update(dt:Float) {
-		if( updateList.length == 0 ) return;
-		for( f in updateList.copy() )
-			if( f(dt) )
+		var i = 0;
+		while (i < updateList.length) {
+			var f = updateList[i];
+			if(f(dt))
 				updateList.remove(f);
+			else
+				++i;
+		}
 	}
-
 }