Bug 838821 - Don't use file.exists() when not necessary (browser/components). r=gavin
authorMarco Castelluccio <mar.castelluccio@studenti.unina.it>
Fri, 08 Feb 2013 11:34:47 -0500
changeset 131212 272789a888359ef27d625e15162d159b666452fd
parent 131211 eca4d9c0301b9c293ba8f5342d3d3f4c3bb59afb
child 131213 92f93ab32aec0dc915ee206ee27825aeeb15d82a
push id2323
push userbbajaj@mozilla.com
push dateMon, 01 Apr 2013 19:47:02 +0000
treeherdermozilla-beta@7712be144d91 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgavin
bugs838821
milestone21.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 838821 - Don't use file.exists() when not necessary (browser/components). r=gavin
browser/components/sessionstore/src/_SessionFile.jsm
--- a/browser/components/sessionstore/src/_SessionFile.jsm
+++ b/browser/components/sessionstore/src/_SessionFile.jsm
@@ -150,22 +150,21 @@ let SessionFileInternal = {
    * initialization.
    */
   syncRead: function ssfi_syncRead() {
     let text;
     let exn;
     TelemetryStopwatch.start("FX_SESSION_RESTORE_SYNC_READ_FILE_MS");
     try {
       let file = new FileUtils.File(this.path);
-      if (!file.exists()) {
-        return null;
-      }
       let chan = NetUtil.newChannel(file);
       let stream = chan.open();
       text = NetUtil.readInputStreamToString(stream, stream.available(), {charset: "utf-8"});
+    } catch (e if e.result == Components.results.NS_ERROR_FILE_NOT_FOUND) {
+      return "";
     } catch(ex) {
       exn = ex;
     } finally {
       TelemetryStopwatch.finish("FX_SESSION_RESTORE_SYNC_READ_FILE_MS");
     }
     if (exn) {
       Cu.reportError(exn);
       return "";