Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
fdcb96e2 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid copy-write-copy pattern in audio data source
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
3b5d642c by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid copy-write-copy pattern in video data source
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
be73eb74 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Leverage mutable copy to acquire mutable path items in
VLCInputNodePathControl
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
0edb6284 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating unneeded copies of generated animation steps in flow
layout
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
84a9d843 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid copy-write-copy pattern in video container view data source
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
052af75c by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating unneeded copies of playlists
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
056ab09d by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating unneeded copies of containers in home view stack view
controller
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
e3e36e56 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating copies where possible during actions in librarymodel
Signed-off-by: Claudio Cambra <[email protected]>
# Conflicts:
#
modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.m
- - - - -
f4a764b1 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating copies where possible during audio group item handling
in library model
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
3ea2ae13 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid creating a subviews array copy in library window
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
ee907c1f by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Avoid double iteration in toolbar delegate by using/reusing index
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
f62ebfa4 by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Do not double-create array in toolbar delegate
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
c9715c5d by Claudio Cambra at 2026-03-01T07:25:32+01:00
macosx: Preallocate matchingTitles size in library window
Signed-off-by: Claudio Cambra <[email protected]>
- - - - -
11 changed files:
- modules/gui/macosx/library/VLCInputNodePathControl.m
- modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
- modules/gui/macosx/library/VLCLibraryModel.m
- modules/gui/macosx/library/VLCLibraryWindow.m
- modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m
- modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
- modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.m
-
modules/gui/macosx/library/home-library/VLCLibraryHomeViewStackViewController.m
-
modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerViewDataSource.m
- modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m
- modules/gui/macosx/library/video-library/VLCLibraryVideoDataSource.m
Changes:
=====================================
modules/gui/macosx/library/VLCInputNodePathControl.m
=====================================
@@ -39,7 +39,7 @@
[self.inputNodePathControlItems setObject:inputNodePathControlItem
forKey:inputNodePathControlItem.image.accessibilityDescription];
- NSMutableArray * const pathItems = [NSMutableArray
arrayWithArray:self.pathItems];
+ NSMutableArray * const pathItems = self.pathItems.mutableCopy;
[pathItems addObject:inputNodePathControlItem];
self.pathItems = pathItems;
}
@@ -51,7 +51,7 @@
return;
}
- NSMutableArray * const pathItems = [NSMutableArray
arrayWithArray:self.pathItems];
+ NSMutableArray * const pathItems = self.pathItems.mutableCopy;
NSPathControlItem * const lastItem = pathItems.lastObject;
[pathItems removeLastObject];
@@ -79,7 +79,7 @@
return;
}
- NSMutableArray<NSPathControlItem *> * const pathItems = [NSMutableArray
arrayWithArray:self.pathItems];
+ NSMutableArray<NSPathControlItem *> * const pathItems =
self.pathItems.mutableCopy;
NSArray<NSPathControlItem *> * const itemsToRemove = [pathItems
subarrayWithRange:NSMakeRange(indexOfItem + 1, pathItems.count - indexOfItem -
1)];
NSMutableArray<NSString *> * const itemIdsToRemove = [NSMutableArray
arrayWithCapacity:itemsToRemove.count];
=====================================
modules/gui/macosx/library/VLCLibraryCollectionViewFlowLayout.m
=====================================
@@ -99,10 +99,10 @@ static CVReturn
detailViewAnimationCallback(CVDisplayLinkRef displayLink,
{
self = [super init];
if (self) {
- _mediumHeightAnimationSteps = [NSArray arrayWithArray:[self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.mediumDetailSupplementaryViewCollectionViewHeight]];
- _largeHeightAnimationSteps = [NSArray arrayWithArray:[self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.largeDetailSupplementaryViewCollectionViewHeight]];
- _mediumWidthAnimationSteps = [NSArray arrayWithArray:[self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.mediumDetailSupplementaryViewCollectionViewWidth]];
- _largeWidthAnimationSteps = [NSArray arrayWithArray:[self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.largeDetailSupplementaryViewCollectionViewWidth]];
+ _mediumHeightAnimationSteps = [self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.mediumDetailSupplementaryViewCollectionViewHeight];
+ _largeHeightAnimationSteps = [self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.largeDetailSupplementaryViewCollectionViewHeight];
+ _mediumWidthAnimationSteps = [self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.mediumDetailSupplementaryViewCollectionViewWidth];
+ _largeWidthAnimationSteps = [self
generateAnimationStepsForExpandedViewDimension:VLCLibraryUIUnits.largeDetailSupplementaryViewCollectionViewWidth];
_animationType = VLCExpandAnimationTypeVerticalMedium;
_prevProvidedAnimationStep = 0;
@@ -126,7 +126,7 @@ static CVReturn
detailViewAnimationCallback(CVDisplayLinkRef displayLink,
generatedAnimationSteps[i] = @(dimension * (progress * progress *
progress + 1) + kDetailViewCollapsedHeight);
}
- return [generatedAnimationSteps copy];
+ return generatedAnimationSteps;
}
- (CGFloat)currentAnimationStep
=====================================
modules/gui/macosx/library/VLCLibraryModel.m
=====================================
@@ -1129,26 +1129,31 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
BOOL (^idCheckBlock)(VLCMediaLibraryMediaItem * const, const
NSUInteger, BOOL * const) = ^BOOL(VLCMediaLibraryMediaItem * const mediaItem,
const NSUInteger __unused idx, BOOL * const __unused stop) {
NSAssert(mediaItem != nil, @"Cache list should not contain nil
media items");
return mediaItem.libraryID == libraryId;
- };
+ };
- // Recents can contain media items the other two do
- NSMutableArray * const recentsMutable =
self.cachedRecentMedia.mutableCopy;
- const NSUInteger recentsIndex = [recentsMutable
indexOfObjectPassingTest:idCheckBlock];
+ // Search immutable arrays first, only copy when modification needed
+ const NSUInteger recentsIndex = [self.cachedRecentMedia
indexOfObjectPassingTest:idCheckBlock];
+ const NSUInteger videoIndex = [self.cachedVideoMedia
indexOfObjectPassingTest:idCheckBlock];
- NSMutableArray * const videoMutable =
self.cachedVideoMedia.mutableCopy;
- const NSUInteger videoIndex = [videoMutable
indexOfObjectPassingTest:idCheckBlock];
if (videoIndex != NSNotFound) {
- NSMutableArray * const showsMutable =
self.cachedListOfShows.mutableCopy;
+ // Found in video cache - search shows for episode match
NSInteger showIndex = NSNotFound;
NSInteger episodeIndex = NSNotFound;
- for (VLCMediaLibraryShow * const show in showsMutable) {
+ NSUInteger currentShowIndex = 0;
+ for (VLCMediaLibraryShow * const show in self.cachedListOfShows) {
episodeIndex = [show.episodes
indexOfObjectPassingTest:idCheckBlock];
- showIndex = [showsMutable indexOfObject:show];
if (episodeIndex != NSNotFound) {
+ showIndex = currentShowIndex;
break;
}
+ currentShowIndex++;
}
+ // Now create mutable copies for modification
+ NSMutableArray * const recentsMutable =
self.cachedRecentMedia.mutableCopy;
+ NSMutableArray * const videoMutable =
self.cachedVideoMedia.mutableCopy;
+ NSMutableArray * const showsMutable =
self.cachedListOfShows.mutableCopy;
+
dispatch_sync(dispatch_get_main_queue(), ^{
action(videoMutable, videoIndex, recentsMutable, recentsIndex,
showsMutable, showIndex, episodeIndex);
self.cachedVideoMedia = videoMutable.copy;
@@ -1157,20 +1162,25 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
return;
}
- NSMutableArray * const recentAudiosMutable =
self.cachedRecentAudioMedia.mutableCopy;
- const NSUInteger recentAudiosIndex = [recentAudiosMutable
indexOfObjectPassingTest:idCheckBlock];
-
- NSMutableArray * const audioMutable =
self.cachedAudioMedia.mutableCopy;
+ // Not in video cache, check audio cache
+ const NSUInteger recentAudiosIndex = [self.cachedRecentAudioMedia
indexOfObjectPassingTest:idCheckBlock];
const NSUInteger audioIndex = [self.cachedAudioMedia
indexOfObjectPassingTest:idCheckBlock];
+
if (audioIndex != NSNotFound) {
+ // Found in audio cache - create mutable copies for modification
+ NSMutableArray * const recentsMutable =
self.cachedRecentMedia.mutableCopy;
+ NSMutableArray * const recentAudiosMutable =
self.cachedRecentAudioMedia.mutableCopy;
+ NSMutableArray * const audioMutable =
self.cachedAudioMedia.mutableCopy;
+
dispatch_sync(dispatch_get_main_queue(), ^{
action(audioMutable, audioIndex, recentAudiosMutable,
recentAudiosIndex, nil, NSNotFound, NSNotFound);
self.cachedAudioMedia = audioMutable.copy;
- self.cachedRecentAudioMedia = recentsMutable.copy;
+ self.cachedRecentAudioMedia = recentAudiosMutable.copy;
});
return;
}
+ // Not found in any cache
action(nil, NSNotFound, nil, NSNotFound, nil, NSNotFound, NSNotFound);
});
}
@@ -1340,14 +1350,13 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
return;
}
- // Block calling queue while we modify the cache, preventing dangerous
concurrent modification
+ // Create mutable copy for modification
NSMutableArray * const mutableAudioGroupCache = [cache mutableCopy];
[mutableAudioGroupCache replaceObjectAtIndex:audioGroupIndex
withObject:audioGroupItem];
- NSArray * const immutableCopy = [mutableAudioGroupCache copy];
const IMP cacheSetterImp = [self methodForSelector:setterSelector];
void (*cacheSetterFunction)(id, SEL, NSArray *) = (void
*)cacheSetterImp;
- cacheSetterFunction(self, setterSelector, immutableCopy);
+ cacheSetterFunction(self, setterSelector, mutableAudioGroupCache.copy);
dispatch_async(dispatch_get_main_queue(), ^{
[self.changeDelegate notifyChange:notificationName
withObject:audioGroupItem];
@@ -1373,13 +1382,13 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
const id<VLCMediaLibraryAudioGroupProtocol> audioGroupItem =
cache[audioGroupIndex];
+ // Create mutable copy for modification
NSMutableArray * const mutableAudioGroupCache = [cache mutableCopy];
[mutableAudioGroupCache removeObjectAtIndex:audioGroupIndex];
- NSArray * const immutableCopy = [mutableAudioGroupCache copy];
const IMP cacheSetterImp = [self methodForSelector:setterSelector];
void (*cacheSetterFunction)(id, SEL, NSArray *) = (void
*)cacheSetterImp;
- cacheSetterFunction(self, setterSelector, immutableCopy);
+ cacheSetterFunction(self, setterSelector, mutableAudioGroupCache.copy);
dispatch_async(dispatch_get_main_queue(), ^{
[self.changeDelegate notifyChange:notificationName
withObject:audioGroupItem];
@@ -1490,11 +1499,11 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
const int64_t itemId = p_event->modification.i_entity_id;
dispatch_barrier_async(_groupCacheModificationQueue, ^{
- NSMutableArray * const mutableGroups =
self.cachedListOfGroups.mutableCopy;
+ // Search immutable array first
const NSUInteger groupIdx =
- [mutableGroups indexOfObjectPassingTest:^BOOL(VLCMediaLibraryGroup
* const group,
- const NSUInteger
__unused idx,
- BOOL * const
__unused stop) {
+ [self.cachedListOfGroups
indexOfObjectPassingTest:^BOOL(VLCMediaLibraryGroup * const group,
+ const
NSUInteger __unused idx,
+ BOOL *
const __unused stop) {
return group.libraryID == itemId;
}];
@@ -1503,7 +1512,10 @@ static void libraryCallback(void *p_data, const
vlc_ml_event_t *p_event)
return;
}
- VLCMediaLibraryGroup * const groupToDelete = mutableGroups[groupIdx];
+ VLCMediaLibraryGroup * const groupToDelete =
self.cachedListOfGroups[groupIdx];
+
+ // Now create mutable copy for modification
+ NSMutableArray * const mutableGroups =
self.cachedListOfGroups.mutableCopy;
[mutableGroups removeObjectAtIndex:groupIdx];
self.cachedListOfGroups = mutableGroups.copy;
=====================================
modules/gui/macosx/library/VLCLibraryWindow.m
=====================================
@@ -97,6 +97,7 @@
#import <vlc_media_library.h>
#import <vlc_url.h>
+const NSUInteger VLCLibrarySearchMaxMatchingTitles = 5;
const CGFloat VLCLibraryWindowMinimalWidth = 604.;
const CGFloat VLCLibraryWindowMinimalHeight = 307.;
const NSUserInterfaceItemIdentifier VLCLibraryWindowIdentifier =
@"VLCLibraryWindow";
@@ -680,9 +681,9 @@ static int ShowController(vlc_object_t * __unused p_this,
context.duration = 1.0;
self.loadingOverlayView.animator.alphaValue = 0.0;
} completionHandler:^{
- NSMutableArray * const views =
self.libraryTargetView.subviews.mutableCopy;
- [views removeObject:self.loadingOverlayView];
- self.libraryTargetView.subviews = views.copy;
+ NSMutableArray * const mutableSubviews =
self.libraryTargetView.subviews.mutableCopy;
+ [mutableSubviews removeObject:self.loadingOverlayView];
+ self.libraryTargetView.subviews = mutableSubviews;
[self.loadingOverlayView.indicator stopAnimation:self];
}];
}
@@ -726,7 +727,7 @@ static int ShowController(vlc_object_t * __unused p_this,
}
NSArray<NSString *> * const allTitles = libraryModel.listOfMediaTitles;
- NSMutableArray<NSString *> * const matchingTitles = [NSMutableArray array];
+ NSMutableArray<NSString *> * const matchingTitles = [NSMutableArray
arrayWithCapacity:VLCLibrarySearchMaxMatchingTitles];
// Filter titles that match the partial word
for (NSString * const title in allTitles) {
@@ -734,7 +735,7 @@ static int ShowController(vlc_object_t * __unused p_this,
continue;
}
[matchingTitles addObject:title];
- if (matchingTitles.count >= 5) {
+ if (matchingTitles.count >= VLCLibrarySearchMaxMatchingTitles) {
break;
}
}
=====================================
modules/gui/macosx/library/VLCLibraryWindowToolbarDelegate.m
=====================================
@@ -174,15 +174,22 @@ NSString * const
VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier =
NSParameterAssert(items != nil);
NSParameterAssert(toolbarItem.itemIdentifier.length > 0);
- const NSInteger toolbarItemIndex = [self.toolbar.items
indexOfObject:toolbarItem];
- if (toolbarItemIndex != NSNotFound) {
+ // Build toolbar item index map once to avoid double iteration
+ NSArray<NSToolbarItem *> * const toolbarItems = self.toolbar.items;
+ NSMapTable * const itemIndexMap = [NSMapTable
strongToStrongObjectsMapTable];
+ for (NSUInteger i = 0; i < toolbarItems.count; i++) {
+ [itemIndexMap setObject:@(i) forKey:toolbarItems[i]];
+ }
+
+ NSNumber * const toolbarItemIndexNumber = [itemIndexMap
objectForKey:toolbarItem];
+ if (toolbarItemIndexNumber != nil) {
return;
}
for (NSToolbarItem * const item in items) {
- const NSInteger itemIndex = [self.toolbar.items indexOfObject:item];
-
- if (itemIndex != NSNotFound) {
+ NSNumber * const itemIndexNumber = [itemIndexMap objectForKey:item];
+ if (itemIndexNumber != nil) {
+ const NSInteger itemIndex = itemIndexNumber.integerValue;
[self.toolbar
insertItemWithItemIdentifier:toolbarItem.itemIdentifier
atIndex:itemIndex + 1];
return;
@@ -239,8 +246,7 @@ NSString * const
VLCLibraryWindowTrackingSeparatorToolbarItemIdentifier =
}
// Display as far to the right as possible, but not in front of the
multifunc bar toggle button
- NSMutableArray<NSToolbarItem *> * const currentToolbarItems =
- [NSMutableArray arrayWithArray:self.toolbar.items];
+ NSMutableArray<NSToolbarItem *> * const currentToolbarItems =
self.toolbar.items.mutableCopy;
if (currentToolbarItems.lastObject == self.togglePlayQueueToolbarItem) {
[currentToolbarItems removeLastObject];
}
=====================================
modules/gui/macosx/library/audio-library/VLCLibraryAudioDataSource.m
=====================================
@@ -77,7 +77,7 @@ NSString * const
VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
@interface VLCLibraryAudioDataSource ()
-@property (readwrite, atomic) NSArray *displayedCollection;
+@property (readwrite, atomic) NSMutableArray *displayedCollection;
@property (readonly) BOOL displayAllArtistsGenresTableEntry;
@end
@@ -531,10 +531,9 @@ NSString * const
VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
_displayedCollectionUpdating = YES;
dispatch_async(dispatch_get_main_queue(), ^{
- self.displayedCollection = [self collectionToDisplay];
+ self.displayedCollection = [[self collectionToDisplay] mutableCopy];
if (self.displayAllArtistsGenresTableEntry) {
- NSMutableArray * const mutableCollectionCopy =
self.displayedCollection.mutableCopy;
VLCLibraryAllAudioGroupsMediaLibraryItem *group;
if (self->_currentParentType ==
VLCMediaLibraryParentGroupTypeGenre) {
@@ -544,8 +543,7 @@ NSString * const
VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
}
NSAssert(group != nil, @"All items group should not be nil");
- [mutableCollectionCopy insertObject:group atIndex:0];
- self.displayedCollection = mutableCollectionCopy;
+ [self.displayedCollection insertObject:group atIndex:0];
}
self->_displayedCollectionUpdating = NO;
@@ -578,9 +576,7 @@ NSString * const
VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
return;
}
- NSMutableArray * const mutableCollectionCopy =
[self.displayedCollection mutableCopy];
- [mutableCollectionCopy replaceObjectAtIndex:index withObject:item];
- self.displayedCollection = [mutableCollectionCopy copy];
+ [self.displayedCollection replaceObjectAtIndex:index withObject:item];
NSIndexPath * const indexPath = [NSIndexPath indexPathForItem:index
inSection:0];
NSIndexSet * const rowIndexSet = [NSIndexSet indexSetWithIndex:index];
@@ -606,9 +602,7 @@ NSString * const
VLCLibraryAudioDataSourceDisplayedCollectionChangedNotification
return;
}
- NSMutableArray * const mutableCollectionCopy =
[self.displayedCollection mutableCopy];
- [mutableCollectionCopy removeObjectAtIndex:index];
- self.displayedCollection = [mutableCollectionCopy copy];
+ [self.displayedCollection removeObjectAtIndex:index];
NSIndexPath * const indexPath = [NSIndexPath indexPathForItem:index
inSection:0];
NSIndexSet * const rowIndexSet = [NSIndexSet indexSetWithIndex:index];
=====================================
modules/gui/macosx/library/favorites-library/VLCLibraryFavoritesDataSource.m
=====================================
@@ -162,7 +162,7 @@ NSString * const
VLCLibraryFavoritesDataSourceDisplayedCollectionChangedNotifica
- (void)updateVisibleSectionMapping
{
- NSMutableArray<NSNumber *> * const visibleSections = [NSMutableArray
array];
+ NSMutableArray<NSNumber *> * const visibleSections = [NSMutableArray
arrayWithCapacity:VLCLibraryFavoritesSectionCount];
for (NSUInteger i = 1; i < VLCLibraryFavoritesSectionCount; i++) {
NSArray * const sectionArray = [self arrayForSection:i];
if (sectionArray.count > 0) {
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewStackViewController.m
=====================================
@@ -46,7 +46,7 @@
@interface VLCLibraryHomeViewStackViewController()
{
- NSArray<NSView<VLCLibraryHomeViewContainerView> *> *_containers;
+ NSMutableArray<NSView<VLCLibraryHomeViewContainerView> *> *_containers;
NSUInteger _leadingContainerCount;
}
@end
@@ -87,7 +87,7 @@
name:VLCLibraryModelRecentAudioMediaItemDeleted
object:nil];
- _containers = @[];
+ _containers = [NSMutableArray array];
_leadingContainerCount = 0;
[self generateCustomContainers];
[self generateGenericCollectionViewContainers];
@@ -125,23 +125,19 @@
- (void)prependRecentItemsContainer:(NSView<VLCLibraryHomeViewContainerView>
*)container
{
- NSMutableArray<NSView<VLCLibraryHomeViewContainerView> *> * const
mutableContainers = _containers.mutableCopy;
[self.collectionsStackView insertArrangedSubview:container
atIndex:_leadingContainerCount];
[self setupContainerView:container withStackView:_collectionsStackView];
- [mutableContainers insertObject:container atIndex:0];
+ [_containers insertObject:container atIndex:0];
++_leadingContainerCount;
- _containers = mutableContainers.copy;
}
- (void)removeRecentItemsContainer:(NSView<VLCLibraryHomeViewContainerView>
*)container
{
[self.collectionsStackView
removeConstraints:container.constraintsWithSuperview];
[self.collectionsStackView removeArrangedSubview:container];
- NSMutableArray<NSView<VLCLibraryHomeViewContainerView> *> * const
mutableContainers = _containers.mutableCopy;
- [mutableContainers removeObject:container];
+ [_containers removeObject:container];
container = nil; // Important to detect whether the view is presented or
not
--_leadingContainerCount;
- _containers = mutableContainers.copy;
}
- (void)recentsChanged:(NSNotification *)notification
@@ -178,16 +174,13 @@
- (void)generateGenericCollectionViewContainers
{
- NSMutableArray<NSView<VLCLibraryHomeViewContainerView> *> * const
mutableContainers = _containers.mutableCopy;
NSUInteger i = VLCMediaLibraryParentGroupTypeRecentVideos + 1;
for (; i <= VLCMediaLibraryParentGroupTypeVideoLibrary; ++i) {
VLCLibraryHomeViewVideoGridContainerView * const containerView =
[[VLCLibraryHomeViewVideoGridContainerView alloc] init];
containerView.videoGroup = i;
- [mutableContainers addObject:containerView];
+ [_containers addObject:containerView];
}
-
- _containers = mutableContainers.copy;
}
- (void)reloadData
=====================================
modules/gui/macosx/library/home-library/VLCLibraryHomeViewVideoContainerViewDataSource.m
=====================================
@@ -49,7 +49,7 @@ NSString * const
VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChang
VLCLibraryModel *_libraryModel;
}
-@property (readwrite, atomic) NSArray *collectionArray;
+@property (readwrite, atomic) NSMutableArray *collectionArray;
@end
@@ -60,7 +60,7 @@ NSString * const
VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChang
self = [super init];
if(self) {
_libraryModel = VLCMain.sharedInstance.libraryController.libraryModel;
- self.collectionArray = [NSArray array];
+ self.collectionArray = [NSMutableArray array];
[self connect];
}
return self;
@@ -203,7 +203,7 @@ NSString * const
VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChang
}
dispatch_async(dispatch_get_main_queue(), ^{
- self.collectionArray = newCollectionArray;
+ self.collectionArray = [newCollectionArray mutableCopy];
[self.collectionView reloadData];
[self.carouselView reloadData];
[NSNotificationCenter.defaultCenter
postNotificationName:VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChangedNotification
@@ -219,9 +219,7 @@ NSString * const
VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChang
return;
}
- NSMutableArray * const mutableCollectionCopy = [self.collectionArray
mutableCopy];
- [mutableCollectionCopy replaceObjectAtIndex:mediaItemIndex
withObject:mediaItem];
- self.collectionArray = [mutableCollectionCopy copy];
+ [self.collectionArray replaceObjectAtIndex:mediaItemIndex
withObject:mediaItem];
NSIndexPath * const indexPath = [NSIndexPath
indexPathForItem:mediaItemIndex inSection:0];
[self.collectionView reloadItemsAtIndexPaths:[NSSet
setWithObject:indexPath]];
@@ -232,14 +230,12 @@ NSString * const
VLCLibraryVideoCollectionViewDataSourceDisplayedCollectionChang
- (void)deleteDataForMediaItem:(VLCMediaLibraryMediaItem * const)mediaItem
{
- NSUInteger mediaItemIndex = [self
indexOfMediaItemInCollection:mediaItem.libraryID];
+ const NSUInteger mediaItemIndex = [self
indexOfMediaItemInCollection:mediaItem.libraryID];
if (mediaItemIndex == NSNotFound) {
return;
}
- NSMutableArray * const mutableCollectionCopy = [self.collectionArray
mutableCopy];
- [mutableCollectionCopy removeObjectAtIndex:mediaItemIndex];
- self.collectionArray = [mutableCollectionCopy copy];
+ [self.collectionArray removeObjectAtIndex:mediaItemIndex];
NSIndexPath * const indexPath = [NSIndexPath
indexPathForItem:mediaItemIndex inSection:0];
[self.collectionView deleteItemsAtIndexPaths:[NSSet
setWithObject:indexPath]];
=====================================
modules/gui/macosx/library/playlist-library/VLCLibraryPlaylistDataSource.m
=====================================
@@ -42,7 +42,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction) {
@interface VLCLibraryPlaylistDataSource ()
-@property (readwrite, atomic) NSArray<VLCMediaLibraryPlaylist *> *playlists;
+@property (readwrite, atomic) NSMutableArray<VLCMediaLibraryPlaylist *>
*playlists;
@end
@@ -120,7 +120,7 @@ typedef NS_ENUM(NSInteger, VLCLibraryDataSourceCacheAction)
{
- (void)reloadData
{
- self.playlists = [self.libraryModel
listOfPlaylistsOfType:self.playlistType];
+ self.playlists = [[self.libraryModel
listOfPlaylistsOfType:self.playlistType] mutableCopy];
[self reloadViews];
}
@@ -174,21 +174,18 @@ typedef NS_ENUM(NSInteger,
VLCLibraryDataSourceCacheAction) {
return;
}
- NSMutableArray * const mutablePlaylists = self.playlists.mutableCopy;
-
switch (action) {
case VLCLibraryDataSourceCacheUpdateAction:
- [mutablePlaylists replaceObjectAtIndex:idx
withObject:playlist];
+ [self.playlists replaceObjectAtIndex:idx withObject:playlist];
break;
case VLCLibraryDataSourceCacheDeleteAction:
- [mutablePlaylists removeObjectAtIndex:idx];
+ [self.playlists removeObjectAtIndex:idx];
break;
default:
NSAssert(false, @"Invalid playlist cache action");
}
dispatch_async(dispatch_get_main_queue(), ^{
- self.playlists = mutablePlaylists.copy;
[self reloadViewsAtIndex:idx dueToCacheAction:action];
});
});
=====================================
modules/gui/macosx/library/video-library/VLCLibraryVideoDataSource.m
=====================================
@@ -44,8 +44,8 @@ NSString * const
VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
@interface VLCLibraryVideoDataSource ()
{
- NSArray *_recentsArray;
- NSArray *_libraryArray;
+ NSMutableArray *_recentsArray;
+ NSMutableArray *_libraryArray;
VLCLibraryCollectionViewFlowLayout *_collectionViewFlowLayout;
NSUInteger _priorNumVideoSections;
}
@@ -170,8 +170,8 @@ NSString * const
VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
[_collectionViewFlowLayout resetLayout];
- self->_recentsArray = [self.libraryModel listOfRecentMedia];
- self->_libraryArray = [self.libraryModel listOfVideoMedia];
+ self->_recentsArray = [[self.libraryModel listOfRecentMedia] mutableCopy];
+ self->_libraryArray = [[self.libraryModel listOfVideoMedia] mutableCopy];
if (self.masterTableView.dataSource == self) {
[self.masterTableView reloadData];
@@ -192,34 +192,24 @@ NSString * const
VLCLibraryVideoDataSourceDisplayedCollectionChangedNotification
arrayOperation:(void(^)(const NSMutableArray*, const
NSUInteger))arrayOperation
completionHandler:(void(^)(const
NSIndexSet*))completionHandler
{
- NSMutableArray *groupMutableCopyArray;
+ NSMutableArray *groupArray;
switch(group) {
case VLCMediaLibraryParentGroupTypeVideoLibrary:
- groupMutableCopyArray = [_libraryArray mutableCopy];
+ groupArray = _libraryArray;
break;
case VLCMediaLibraryParentGroupTypeRecentVideos:
- groupMutableCopyArray = [_recentsArray mutableCopy];
+ groupArray = _recentsArray;
break;
default:
return;
}
- NSUInteger mediaItemIndex = [self indexOfMediaItem:mediaItem.libraryID
inArray:groupMutableCopyArray];
+ const NSUInteger mediaItemIndex = [self
indexOfMediaItem:mediaItem.libraryID inArray:groupArray];
if (mediaItemIndex == NSNotFound) {
return;
}
- arrayOperation(groupMutableCopyArray, mediaItemIndex);
- switch(group) {
- case VLCMediaLibraryParentGroupTypeVideoLibrary:
- _libraryArray = [groupMutableCopyArray copy];
- break;
- case VLCMediaLibraryParentGroupTypeRecentVideos:
- _recentsArray = [groupMutableCopyArray copy];
- break;
- default:
- return;
- }
+ arrayOperation(groupArray, mediaItemIndex);
NSIndexSet * const rowIndexSet = [NSIndexSet
indexSetWithIndex:mediaItemIndex];
completionHandler(rowIndexSet);
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/1499dacef4d5a37bca88fee5b95a0e508807059f...c9715c5dd9451cc37792bb82c20a88209892cd8b
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/1499dacef4d5a37bca88fee5b95a0e508807059f...c9715c5dd9451cc37792bb82c20a88209892cd8b
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance_______________________________________________
vlc-commits mailing list
[email protected]
https://mailman.videolan.org/listinfo/vlc-commits