• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Optimizing Enormous lists in NSBrowser
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Optimizing Enormous lists in NSBrowser


  • Subject: Optimizing Enormous lists in NSBrowser
  • From: Dave DeLong <email@hidden>
  • Date: Thu, 17 Sep 2009 15:32:06 -0600

Hi everyone,

I'm recreating a Finder-like column view fro browsing the disk, and I've come up against some optimization impasses.

First off, I'm using passive-loading, so that I only load information regarding an item once I get the browser:willDisplayCell: message. This works wonderfully for lazy loading.

My problem lies before that. I'm trying to mimic the Finder, so I want to not show hidden files if they're not visible in Finder. When I obtain a directory listing via NSFileManager, it includes everything (including hidden files). Once I get that listing, I filter it based with an "isFileVisible = YES" predicate, which calls an -[NSString isFileVisible] method I've implemented in a category. This method checks the three standard ways of hiding a file to determine its visibility (prefixed with ".", a flipped invisible bit, or listing it in /.hidden [which is deprecated, but I need to support older systems]).

Once I've filtered the array, I sort it using a custom "compareLikeFinder:" method, which sorts items into the same order as they appear in Finder.

For normal-sized directories, this works pretty well. However, in my "worst-case" scenario of a flat directory containing 1 million files, I've found that it takes 34.8 seconds to retrieve a full directory listing (so I know how many to return in browser:numberOfRowsInColumn:), 301.5 seconds to filter the array, and another 73.6 seconds to sort it.

Believe it or not, this is actually better than the current implementation, but I'd like to do even better. On that note, here are my questions:

1. How can I obtain a count of files in a directory without retrieving the actual listing of contents? (I can scan through the folder and count by just grabbing catalog infos myself, but is there a faster way?)
2. How can I retrieve the name of the nth item in a directory without retrieving the actual listing of contents?


Thanks!

Dave DeLong
_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Optimizing Enormous lists in NSBrowser
      • From: Jean-Francois Dontigny <email@hidden>
    • Re: Optimizing Enormous lists in NSBrowser
      • From: Jens Alfke <email@hidden>
  • Prev by Date: iPhone Pref changes
  • Next by Date: Re: Reg: outlineView dataSource method outlineView:child:ofItem:
  • Previous by thread: iPhone Pref changes
  • Next by thread: Re: Optimizing Enormous lists in NSBrowser
  • Index(es):
    • Date
    • Thread