Bug 1325713 - remove unnecessary query of nsIURI to nsIURL. r=aceman a=jorgk
authorJorg K <jorgk@jorgk.com>
Thu, 29 Dec 2016 13:52:23 +0100
changeset 26889 dc9b6f9bb194387a21508832d0c02eed865ea70e
parent 26888 9152817cd3676dd5d9ca64bee508c36d67872a6d
child 26890 d9b7c9856c1a2537f33e3b7d99ba0fb365f31076
push id1834
push userclokep@gmail.com
push dateMon, 23 Jan 2017 21:48:40 +0000
treeherdercomm-beta@293cffe83e59 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaceman, jorgk
bugs1325713
Bug 1325713 - remove unnecessary query of nsIURI to nsIURL. r=aceman a=jorgk
mail/components/compose/content/MsgComposeCommands.js
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -4341,35 +4341,32 @@ function OpenSelectedAttachment()
     {
       // we must be dealing with a forwarded attachment, treat this special
       let msgHdr = gMessenger.messageServiceFromURI(attachmentUrl).messageURIToMsgHdr(attachmentUrl);
       if (msgHdr)
         MailUtils.openMessageInNewWindow(msgHdr);
     }
     else
     {
-      // turn the url into a nsIURL object then open it
-
-      let url = Services.io.newURI(attachmentUrl, null, null);
-      url = url.QueryInterface( Components.interfaces.nsIURL );
-
-      if (url)
+      // Turn the URL into a nsIURI object then open it.
+      let uri = Services.io.newURI(attachmentUrl, null, null);
+      if (uri)
       {
-        let channel = Services.io.newChannelFromURI2(url,
+        let channel = Services.io.newChannelFromURI2(uri,
                                                      null,
                                                      Services.scriptSecurityManager.getSystemPrincipal(),
                                                      null,
                                                      Components.interfaces.nsILoadInfo.SEC_NORMAL,
                                                      Components.interfaces.nsIContentPolicy.TYPE_OTHER);
         if (channel)
         {
           let uriLoader = Components.classes["@mozilla.org/uriloader;1"].getService(Components.interfaces.nsIURILoader);
           uriLoader.openURI(channel, true, new nsAttachmentOpener());
-        } // if channel
-      } // if url
+        }
+      }
     }
   } // if one attachment selected
 }
 
 function nsAttachmentOpener()
 {
 }
 
@@ -5649,27 +5646,26 @@ function loadBlockedImage(aURL) {
   if (/^file:/i.test(aURL)) {
     filename = aURL.substr(aURL.lastIndexOf("/") + 1);
   }
   else {
     let fnMatch = /[?&;]filename=([^?&]+)/.exec(aURL);
     filename = (fnMatch && fnMatch[1]) || "";
   }
   filename = decodeURIComponent(filename);
-  let url = Services.io.newURI(aURL, null, null);
+  let uri = Services.io.newURI(aURL, null, null);
   let contentType = Components.classes["@mozilla.org/mime;1"]
     .getService(Components.interfaces.nsIMIMEService)
-    .getTypeFromURI(url);
+    .getTypeFromURI(uri);
   if (!contentType.startsWith("image/")) {
     // Unsafe to unblock this. It would just be garbage either way.
-    throw new Error("Won't unblock; url=" + aURL +
+    throw new Error("Won't unblock; URL=" + aURL +
                     ", contentType=" + contentType);
   }
-  url = url.QueryInterface(Components.interfaces.nsIURL);
-  let channel = Services.io.newChannelFromURI2(url,
+  let channel = Services.io.newChannelFromURI2(uri,
     null,
     Services.scriptSecurityManager.getSystemPrincipal(),
     null,
     Components.interfaces.nsILoadInfo.SEC_NORMAL,
     Components.interfaces.nsIContentPolicy.TYPE_OTHER);
   let inputStream = channel.open();
   let stream = Components.classes["@mozilla.org/binaryinputstream;1"]
     .createInstance(Components.interfaces.nsIBinaryInputStream);