Bug 1389836 - Don't recreate mHandlerInfo for every little change. r=bz draft
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 14 Nov 2017 15:37:47 -0800
changeset 697910 16288c3e1c4ec701baad773bb00bffee6b309147
parent 697909 459caf229cd0a48889c6ad0bb21cace4d7042b08
child 740244 85b7445760791e425e8555abc9111c5b0ca149d5
push id89140
push userbmo:mrbkap@mozilla.com
push dateTue, 14 Nov 2017 23:40:39 +0000
reviewersbz
bugs1389836
milestone58.0a1
Bug 1389836 - Don't recreate mHandlerInfo for every little change. r=bz There are non-cost reference return values on IPDL structs. We should take advantage of them in order not to recopy everything everytime something changes. MozReview-Commit-ID: D4hG2moE3f
uriloader/exthandler/HandlerServiceParent.cpp
--- a/uriloader/exthandler/HandlerServiceParent.cpp
+++ b/uriloader/exthandler/HandlerServiceParent.cpp
@@ -71,25 +71,18 @@ NS_IMETHODIMP ProxyHandlerInfo::GetPrefe
 NS_IMETHODIMP ProxyHandlerInfo::SetPreferredApplicationHandler(nsIHandlerApp *aApp)
 {
   nsString name;
   nsString detailedDescription;
   if (aApp) {
     aApp->GetName(name);
     aApp->GetDetailedDescription(detailedDescription);
   }
-  HandlerApp happ(name, detailedDescription);
-  mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
-                             mHandlerInfo.isMIMEInfo(),
-                             mHandlerInfo.description(),
-                             mHandlerInfo.alwaysAskBeforeHandling(),
-                             mHandlerInfo.extensions(),
-                             happ,
-                             mHandlerInfo.possibleApplicationHandlers(),
-                             mHandlerInfo.preferredAction());
+
+  mHandlerInfo.preferredApplicationHandler() = HandlerApp(name, detailedDescription);
   return NS_OK;
 }
 
 /* readonly attribute nsIMutableArray possibleApplicationHandlers; */
 NS_IMETHODIMP ProxyHandlerInfo::GetPossibleApplicationHandlers(nsIMutableArray * *aPossibleApplicationHandlers)
 {
   *aPossibleApplicationHandlers = mPossibleApps;
   NS_IF_ADDREF(*aPossibleApplicationHandlers);
@@ -117,44 +110,30 @@ NS_IMETHODIMP ProxyHandlerInfo::LaunchWi
 /* attribute ProxyHandlerInfoAction preferredAction; */
 NS_IMETHODIMP ProxyHandlerInfo::GetPreferredAction(nsHandlerInfoAction *aPreferredAction)
 {
   *aPreferredAction = mPrefAction;
   return NS_OK;
 }
 NS_IMETHODIMP ProxyHandlerInfo::SetPreferredAction(nsHandlerInfoAction aPreferredAction)
 {
-  mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
-                             mHandlerInfo.isMIMEInfo(),
-                             mHandlerInfo.description(),
-                             mHandlerInfo.alwaysAskBeforeHandling(),
-                             mHandlerInfo.extensions(),
-                             mHandlerInfo.preferredApplicationHandler(),
-                             mHandlerInfo.possibleApplicationHandlers(),
-                             aPreferredAction);
+  mHandlerInfo.preferredAction() = aPreferredAction;
   mPrefAction = aPreferredAction;
   return NS_OK;
 }
 
 /* attribute boolean alwaysAskBeforeHandling; */
 NS_IMETHODIMP ProxyHandlerInfo::GetAlwaysAskBeforeHandling(bool *aAlwaysAskBeforeHandling)
 {
   *aAlwaysAskBeforeHandling = mHandlerInfo.alwaysAskBeforeHandling();
   return NS_OK;
 }
 NS_IMETHODIMP ProxyHandlerInfo::SetAlwaysAskBeforeHandling(bool aAlwaysAskBeforeHandling)
 {
-  mHandlerInfo = HandlerInfo(mHandlerInfo.type(),
-                             mHandlerInfo.isMIMEInfo(),
-                             mHandlerInfo.description(),
-                             aAlwaysAskBeforeHandling,
-                             mHandlerInfo.extensions(),
-                             mHandlerInfo.preferredApplicationHandler(),
-                             mHandlerInfo.possibleApplicationHandlers(),
-                             mHandlerInfo.preferredAction());
+  mHandlerInfo.alwaysAskBeforeHandling() = aAlwaysAskBeforeHandling;
   return NS_OK;
 }
 
 
 class ProxyMIMEInfo : public nsIMIMEInfo
 {
 public:
   NS_DECL_ISUPPORTS