Skip to content

Commit 57474e2

Browse files
committed
Refactor and optimize equals
- Remove multiple casts of obj - Simply use object equals on the streams because PlayQueueItem’s equals already compares urls
1 parent 139ced8 commit 57474e2

1 file changed

Lines changed: 3 additions & 11 deletions

File tree

app/src/main/java/org/schabi/newpipe/player/playqueue/PlayQueue.java

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -500,22 +500,14 @@ public synchronized boolean previous() {
500500
* we don't have to do anything with new queue.
501501
* This method also gives a chance to track history of items in a queue in
502502
* VideoDetailFragment without duplicating items from two identical queues
503-
* */
503+
*/
504504
@Override
505505
public boolean equals(@Nullable final Object obj) {
506-
if (!(obj instanceof PlayQueue)
507-
|| getStreams().size() != ((PlayQueue) obj).getStreams().size()) {
506+
if (!(obj instanceof PlayQueue)) {
508507
return false;
509508
}
510-
511509
final PlayQueue other = (PlayQueue) obj;
512-
for (int i = 0; i < getStreams().size(); i++) {
513-
if (!getItem(i).getUrl().equals(other.getItem(i).getUrl())) {
514-
return false;
515-
}
516-
}
517-
518-
return true;
510+
return streams.equals(other.streams);
519511
}
520512

521513
public boolean isDisposed() {

0 commit comments

Comments
 (0)