Bug 1389836 - Don't recreate mHandlerInfo for every little change. r=bz a=gchang
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 14 Nov 2017 15:37:47 -0800
changeset 442503 35e083bb82efff62d48a0ca947816ab44d38eb81
parent 442502 f459b78ab427b120ceb6320565dfe77b77247414
child 442504 33e95d96edd254f38dcd29bae7f9974ebfeea703
push id8236
push userapavel@mozilla.com
push dateMon, 27 Nov 2017 10:06:01 +0000
treeherdermozilla-beta@47c97637717f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, gchang
bugs1389836
milestone58.0
Bug 1389836 - Don't recreate mHandlerInfo for every little change. r=bz a=gchang 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