[vlc-commits] macosx: remove unneeded containsObject calls, fix UInt underflow, fix array cleaning

David Fuhrmann git at videolan.org
Sun Apr 27 21:04:33 CEST 2014


vlc | branch: master | David Fuhrmann <dfuhrmann at videolan.org> | Sun Apr 27 21:00:48 2014 +0200| [888571301018c3803ec3852a1ab8732daab16b4e] | committer: David Fuhrmann

macosx: remove unneeded containsObject calls, fix UInt underflow, fix array cleaning

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=888571301018c3803ec3852a1ab8732daab16b4e
---

 modules/gui/macosx/intf.m |   20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/modules/gui/macosx/intf.m b/modules/gui/macosx/intf.m
index dbab132..79d7c6e 100644
--- a/modules/gui/macosx/intf.m
+++ b/modules/gui/macosx/intf.m
@@ -1516,21 +1516,19 @@ static VLCMain *_o_sharedMainInstance = nil;
 
                 if (pos.f_float > .05 && pos.f_float < .95 && dur > 180) {
                     [mutDict setObject:[NSNumber numberWithInt:current_pos_in_sec] forKey:url];
-                    if ([mediaList containsObject:url])
-                         [mediaList removeObject:url];
+
+                    [mediaList removeObject:url];
                     [mediaList addObject:url];
-                    if (mediaList.count > 30) {
-                        NSUInteger count = mediaList.count;
-                        for (NSUInteger x = 0; x < 30 - count; x++) {
-                            [mutDict removeObjectForKey:mediaList[x]];
-                            [mediaList removeObject:mediaList[x]];
+                    NSUInteger mediaListCount = mediaList.count;
+                    if (mediaListCount > 30) {
+                        for (NSUInteger x = 0; x < mediaListCount - 30; x++) {
+                            [mutDict removeObjectForKey:[mediaList objectAtIndex:0]];
+                            [mediaList removeObjectAtIndex:0];
                         }
                     }
                 } else {
-                    if ([mediaList containsObject:url]) {
-                        [mutDict removeObjectForKey:url];
-                        [mediaList removeObject:url];
-                    }
+                    [mutDict removeObjectForKey:url];
+                    [mediaList removeObject:url];
                 }
                 [defaults setObject:mutDict forKey:@"recentlyPlayedMedia"];
                 [defaults setObject:mediaList forKey:@"recentlyPlayedMediaList"];



More information about the vlc-commits mailing list