Optimize getCostumeIndexByName

This commit is contained in:
Thomas Weber committed 2020-12-15 17:39:05 -06:00
1 parent 63aefc6231
commit b06ef7eec5
1 file changed
+3 -2
+3 -2
View File
@@ -598,8 +598,9 @@ class RenderedTarget extends Target {
* @return {number} Index of the named costume, or -1 if not present.
*/
getCostumeIndexByName (costumeName) {
for (let i = 0; i < this.sprite.costumes.length; i++) {
if (this.getCostumes()[i].name === costumeName) {
const costumes = this.getCostumes();
for (let i = 0; i < costumes.length; i++) {
if (costumes[i].name === costumeName) {
return i;
}
}