Hexer10 / youtube_explode_dart

Dart library to interact with many Youtube APIs
https://pub.dev/packages/youtube_explode_dart
BSD 3-Clause "New" or "Revised" License
299 stars 122 forks source link

[BUG] UnmodifiableListView has a huge performance impact on captions iteration #251

Closed kevinzhow closed 1 year ago

kevinzhow commented 1 year ago

Describe the bug i'm using var track = await yt.videos.closedCaptions.get(trackInfo); to get the captions and need to do map on track.captions but the UnmodifiableListView is very slow on operator [](int index). It takes about 8 seconds to finish the for in operation, in my case, over 1600 captions.

Below is my test code.

 final tempList = track.captions;
 final listLength = track.captions.length;
 print(DateTime.now());
 while (index < listLength) {
      var caption = tempList[index];
      index++;
 }
 print(DateTime.now());

Want to know why we are using UnmodifiableListView?