[vlc-commits] [Git][videolan/vlc][master] macosx: Prevent unnecessary list fetches in VLCLibraryModel when querying for...

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Thu Aug 17 11:14:29 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
55473bb0 by Claudio Cambra at 2023-08-17T11:00:23+00:00
macosx: Prevent unnecessary list fetches in VLCLibraryModel when querying for number of media, just use the appropriate porperty

Signed-off-by: Claudio Cambra <developer at claudiocambra.com>

- - - - -


2 changed files:

- modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m


Changes:

=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioViewController.m
=====================================
@@ -374,7 +374,7 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     const VLCAudioLibrarySegment audioLibrarySegment = _audioSegmentedControl.selectedSegment;
     _audioDataSource.audioLibrarySegment = audioLibrarySegment;
 
-    if (_audioDataSource.libraryModel.listOfAudioMedia.count == 0) {
+    if (_audioDataSource.libraryModel.numberOfAudioMedia == 0) {
         [self presentPlaceholderAudioView];
     } else {
         [self prepareAudioLibraryView];
@@ -427,11 +427,11 @@ NSString *VLCLibraryPlaceholderAudioViewIdentifier = @"VLCLibraryPlaceholderAudi
     NSParameterAssert(aNotification);
     VLCLibraryModel *model = (VLCLibraryModel *)aNotification.object;
     NSAssert(model, @"Notification object should be a VLCLibraryModel");
-    NSArray<VLCMediaLibraryMediaItem *> * audioList = model.listOfAudioMedia;
+    const NSUInteger audioCount = model.numberOfAudioMedia;
 
     if (_segmentedTitleControl.selectedSegment == VLCLibraryMusicSegment &&
-        ((audioList.count == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
-         (audioList.count > 0 && ![_libraryTargetView.subviews containsObject:_audioLibraryView])) &&
+        ((audioCount == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
+         (audioCount > 0 && ![_libraryTargetView.subviews containsObject:_audioLibraryView])) &&
         _libraryWindow.videoViewController.view.hidden) {
 
         [self updatePresentedView];


=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoViewController.m
=====================================
@@ -231,11 +231,11 @@
 {
     NSParameterAssert(aNotification);
     VLCLibraryModel *model = VLCMain.sharedInstance.libraryController.libraryModel;
-    NSArray<VLCMediaLibraryMediaItem *> * videoList = model.listOfVideoMedia;
+    const NSUInteger videoCount = model.numberOfVideoMedia;
 
     if (_segmentedTitleControl.selectedSegment == VLCLibraryVideoSegment &&
-        ((videoList.count == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
-         (videoList.count > 0 && ![_libraryTargetView.subviews containsObject:_videoLibraryView])) &&
+        ((videoCount == 0 && ![_libraryTargetView.subviews containsObject:_emptyLibraryView]) ||
+         (videoCount > 0 && ![_libraryTargetView.subviews containsObject:_videoLibraryView])) &&
         _libraryWindow.videoViewController.view.hidden) {
 
         [self updatePresentedView];



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55473bb0fe8fb4d6664599bb0a80f5d8ea761029

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/55473bb0fe8fb4d6664599bb0a80f5d8ea761029
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list