Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Refactor item stack a bit.

  • Loading branch information...
commit 4786c8a898a0bf078bca9abb7dcf19d155efd19f 1 parent dfaac8d
@alloy authored
Showing with 30 additions and 14 deletions.
  1. +30 −14 src/MacVim/MMFileBrowserController.m
View
44 src/MacVim/MMFileBrowserController.m
@@ -149,6 +149,31 @@ - (NSString *)description;
//}
//}
+static void
+MMFileBrowserFSItemStackIncrease(NSArray *stack,
+ MMFileBrowserFSItem *newItem,
+ NSMutableArray **newChildren,
+ BOOL *checkChildrenForExistingItem)
+{
+ BOOL check = NO;
+ // Use an existing children list if this dir has been loaded before.
+ if (newItem.children) {
+ check = YES;
+ newChildren = newItem.children;
+ } else {
+ newChildren = [NSMutableArray new];
+ newItem.children = newChildren;
+ [newChildren release];
+ }
+ *checkChildrenForExistingItem = check;
+ NSArray *stackEntry = [[NSArray alloc] initWithObjects:newItem,
+ newChildren,
+ [NSNumber numberWithBool:check],
+ nil];
+ [stack addObject:stackEntry];
+ [stackEntry release];
+}
+
- (BOOL)loadChildrenRecursive:(BOOL)recursive expandedChildrenOnly:(BOOL)expandedChildrenOnly;
{
// Only reload items that have been loaded before
@@ -244,22 +269,13 @@ - (BOOL)loadChildrenRecursive:(BOOL)recursive expandedChildrenOnly:(BOOL)expande
[child release];
}
- // Set the new child as the current item and give it a new children array.
+ // Set the new child as the current item and the current children.
if (dir) {
currentItem = child;
- // Use an existing children list if this dir has been loaded before.
- if (currentItem.children) {
- checkChildrenForExistingItem = YES;
- currentChildren = currentItem.children;
- } else {
- checkChildrenForExistingItem = NO;
- currentChildren = [NSMutableArray new];
- currentItem.children = currentChildren;
- [currentChildren release];
- }
- currentItemAndChildren = [[NSArray alloc] initWithObjects:currentItem, currentChildren, [NSNumber numberWithBool:checkChildrenForExistingItem], nil];
- [stack addObject:currentItemAndChildren];
- [currentItemAndChildren release];
+ MMFileBrowserFSItemStackIncrease(stack,
+ currentItem,
+ &currentChildren,
+ &checkChildrenForExistingItem);
childrenStackLevel++;
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.