Chromium Code Reviews| Index: chrome/browser/cocoa/cookie_tree_node.mm |
| diff --git a/chrome/browser/cocoa/cookie_tree_node.mm b/chrome/browser/cocoa/cookie_tree_node.mm |
| index 00ef5bc083f02485d4cbbdb3e277fbc54686412a..dccc857b97e5dfde2de0630d061478d7529aeb72 100644 |
| --- a/chrome/browser/cocoa/cookie_tree_node.mm |
| +++ b/chrome/browser/cocoa/cookie_tree_node.mm |
| @@ -15,15 +15,7 @@ |
| if ((self = [super init])) { |
| DCHECK(node); |
| treeNode_ = node; |
| - |
| - const int childCount = node->GetChildCount(); |
| - children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); |
| - for (int i = 0; i < childCount; ++i) { |
| - CookieTreeNode* child = node->GetChild(i); |
| - scoped_nsobject<CocoaCookieTreeNode> childNode( |
| - [[CocoaCookieTreeNode alloc] initWithNode:child]); |
| - [children_ addObject:childNode.get()]; |
| - } |
| + isLeaf_ = (node->GetChildCount() == 0); |
|
John Grabowski
2010/02/01 07:52:06
Not sure why there is a need for a local variable
|
| [self rebuild]; |
| } |
| @@ -67,7 +59,7 @@ |
| } |
| - (BOOL)isLeaf { |
| - return ([children_ count] == 0); |
| + return isLeaf_; |
| } |
| - (NSString*)title { |
| @@ -75,7 +67,17 @@ |
| } |
| - (NSMutableArray*)children { |
| - return children_.get(); |
| + if (!children_.get()) { |
| + const int childCount = treeNode_->GetChildCount(); |
| + children_.reset([[NSMutableArray alloc] initWithCapacity:childCount]); |
| + for (int i = 0; i < childCount; ++i) { |
| + CookieTreeNode* child = treeNode_->GetChild(i); |
| + scoped_nsobject<CocoaCookieTreeNode> childNode( |
| + [[CocoaCookieTreeNode alloc] initWithNode:child]); |
| + [children_ addObject:childNode.get()]; |
| + } |
| + } |
| + return children_.get(); |
| } |
| - (TreeModelNode*)treeNode { |