Skip to content

Commit 6c0975d

Browse files
hviannaBorewit
andauthored
more efficient generation of retrievelQueue
Co-authored-by: Borewit <[email protected]>
1 parent 188828e commit 6c0975d

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3303,7 +3303,13 @@ async function retrieveBackgrounds() {
33033303
async function retrieveMetadata() {
33043304

33053305
// find the first MAX_METADATA_REQUESTS items for which we haven't retrieved the metadata yet
3306-
const retrievalQueue = Array.from(playlist.children).filter(el => el.dataset.retrieve).slice(0, MAX_METADATA_REQUESTS);
3306+
const retrievalQueue = [];
3307+
for (const el of playlist.children) {
3308+
if (el.dataset.retrieve) {
3309+
retrievalQueue.push(el);
3310+
if (retrievalQueue.length >= MAX_METADATA_REQUESTS) break;
3311+
}
3312+
}
33073313

33083314
// Process in parallel
33093315
return Promise.all(retrievalQueue.map(async queueItem => {

0 commit comments

Comments
 (0)