1
0
mirror of https://github.com/TeamNewPipe/NewPipe synced 2025-07-20 02:42:58 +00:00

slightly optimized model

This commit is contained in:
zelva 2022-09-02 21:35:02 +03:00 committed by TobiGr
parent 3513f7ac03
commit 16a83dc448

View File

@ -341,21 +341,22 @@ public abstract class PlayQueue implements Serializable {
final int currentIndex = queueIndex.get(); final int currentIndex = queueIndex.get();
final int size = size(); final int size = size();
int nextIndex = currentIndex;
if (currentIndex > removeIndex) { if (currentIndex > removeIndex) {
queueIndex.decrementAndGet(); nextIndex = currentIndex - 1;
queueIndex.set(nextIndex);
} else if (currentIndex >= size) { } else if (currentIndex >= size) {
queueIndex.set(currentIndex % (size - 1)); nextIndex = currentIndex % (size - 1);
queueIndex.set(nextIndex);
} else if (currentIndex == removeIndex && currentIndex == size - 1) { } else if (currentIndex == removeIndex && currentIndex == size - 1) {
queueIndex.set(0); queueIndex.set(nextIndex = 0);
} }
if (backup != null) { if (backup != null) {
backup.remove(getItem(removeIndex)); backup.remove(getItem(removeIndex));
} }
final int nextIndex = queueIndex.get();
history.remove(streams.remove(removeIndex)); history.remove(streams.remove(removeIndex));
if (streams.size() > nextIndex) { if (streams.size() > nextIndex) {
history.add(streams.get(nextIndex)); history.add(streams.get(nextIndex));