Bug 662164 - Use fast iteration in nsFilePicker.mm. r=joshmoz
authorMounir Lamouri <mounir.lamouri@gmail.com>
Thu, 09 Jun 2011 11:28:16 +0200
changeset 70824 6505311f004a9dee0b270a366da65d25424fc857
parent 70823 a5023d153e7e436c34f63f79cab5ee62f007792c
child 70825 83056e76eeefb9e4f4a12a4a757d8f2a3206b5d2
push id20425
push usereakhgari@mozilla.com
push dateThu, 09 Jun 2011 22:29:39 +0000
treeherdermozilla-central@da8f7ac2a16d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjoshmoz
bugs662164
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 662164 - Use fast iteration in nsFilePicker.mm. r=joshmoz
widget/src/cocoa/nsFilePicker.mm
--- a/widget/src/cocoa/nsFilePicker.mm
+++ b/widget/src/cocoa/nsFilePicker.mm
@@ -397,22 +397,19 @@ nsFilePicker::GetLocalFiles(const nsStri
   nsCocoaUtils::CleanUpAfterNativeAppModalDialog();
   
   if (result == NSFileHandlingPanelCancelButton)
     return retVal;
 
   // Converts data from a NSArray of NSURL to the returned format.
   // We should be careful to not call [thePanel URLs] more than once given that
   // it creates a new array each time.
-  // TODO: we should use Fast Enumeration as soon as Obj-C 2.0 is allowed in
-  // our code.
-  NSArray* urls = [thePanel URLs];
-
-  for (unsigned int i = 0; i < [urls count]; ++i) {
-    NSURL* url = [urls objectAtIndex:i];
+  // We are using Fast Enumeration, thus the NSURL array is created once then
+  // iterated.
+  for (NSURL* url in [thePanel URLs]) {
     if (!url) {
       continue;
     }
 
     nsCOMPtr<nsILocalFile> localFile;
     NS_NewLocalFile(EmptyString(), PR_TRUE, getter_AddRefs(localFile));
     nsCOMPtr<nsILocalFileMac> macLocalFile = do_QueryInterface(localFile);
     if (macLocalFile && NS_SUCCEEDED(macLocalFile->InitWithCFURL((CFURLRef)url))) {