Optimize getCostumeIndexByName
This commit is contained in:
1 file changed
+3
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user