Anonymous avatar Anonymous committed bdafd86

Added -[BWTabViewController countOfViewControllers] to improve efficiency and ease leak hunting

Comments (0)

Files changed (2)

BWTabViewController.h

 #pragma mark Managing the View Controllers
 
 @property(nonatomic, copy, readonly) NSArray *viewControllers;
+- (NSUInteger)countOfViewControllers;  // improves efficiency & eases leak hunting
+
 - (void)insertViewController:(NSViewController *)controller atIndex:(NSUInteger)index;
 - (void)addViewController:(NSViewController *)controller;
 - (void)removeViewController:(NSViewController *)controller;

BWTabViewController.m

     return [[_viewControllers copy] autorelease];
 }
 
+- (NSUInteger)countOfViewControllers;
+{
+    return [_viewControllers count];
+}
+
 - (void)insertViewController:(NSViewController *)controller atIndex:(NSUInteger)index;
 {
     // Store controller
-    NSArray *oldViewControllers = [self viewControllers];
+    NSUInteger oldCount = [self countOfViewControllers];
     [_viewControllers insertObject:controller atIndex:index];
     
      
     
     
     //  If this was the first controller to be inserted, also want to force it to be selected otherwise NSTabView doesn't report a change to selectedIndex
-    if ([oldViewControllers count] == 0) [self setSelectedViewController:controller];
+    if (oldCount == 0) [self setSelectedViewController:controller];
 }
 
 - (void)addViewController:(NSViewController *)controller;
 {
-    [self insertViewController:controller atIndex:[[self viewControllers] count]];
+    [self insertViewController:controller atIndex:[self countOfViewControllers]];
 }
 
 - (void)removeViewController:(NSViewController *)controller;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.