Fixed: #1687 Slow speed of cyclic tags detection

This commit is contained in:
Jindra Petřík
2021-11-19 13:03:23 +01:00
parent d393d1858b
commit 10992b091f
3 changed files with 58 additions and 26 deletions
@@ -323,8 +323,7 @@ public class Timeline {
}
CharacterTag character = swf.getCharacter(characterId);
if (character instanceof DefineSpriteTag) {
Stack<Integer> cyStack = new Stack<>();
if (isCyclic(timelined, cyStack)) {
if (swf.getCyclicCharacters().contains(characterId)) {
fl.characterId = -1;
}
}
@@ -1393,28 +1392,4 @@ public class Timeline {
return false;
}
private boolean isCyclic(Timelined tim, Stack<Integer> walked) {
for (Tag t : tim.getTags()) {
if (t instanceof PlaceObjectTypeTag) {
PlaceObjectTypeTag p = (PlaceObjectTypeTag) t;
int chid = p.getCharacterId();
if (chid != -1) {
if (walked.contains(chid)) {
return true;
}
CharacterTag character = swf.getCharacter(chid);
if (character instanceof DefineSpriteTag) {
walked.push(chid);
if (isCyclic((DefineSpriteTag) character, walked)) {
walked.pop();
return true;
}
walked.pop();
}
}
}
}
return false;
}
}