Bug 1266401 - stop constructing temporary strings in Android's appshell; r=snorp
authorNathan Froyd <froydnj.com>
Thu, 21 Apr 2016 12:52:42 -0400
changeset 294270 abadd42a8e35e2e574666f62450774130d3170df
parent 294269 343ae5fe88d42cdfa8fff4655b430e855bb15a5d
child 294271 fb4131318add3451da9aea822130078ad4d02c18
push id75491
push usernfroyd@mozilla.com
push dateThu, 21 Apr 2016 16:55:10 +0000
treeherdermozilla-inbound@abadd42a8e35 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssnorp
bugs1266401
milestone48.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 1266401 - stop constructing temporary strings in Android's appshell; r=snorp We don't have to construct temporary strings to get at the raw characters of a string.
widget/android/AndroidJavaWrappers.h
widget/android/nsAppShell.cpp
--- a/widget/android/AndroidJavaWrappers.h
+++ b/widget/android/AndroidJavaWrappers.h
@@ -478,19 +478,19 @@ public:
     const nsTArray<int>& ToolTypes() { return mToolTypes; }
     const nsTArray<float>& Orientations() { return mOrientations; }
     const nsTArray<nsIntPoint>& PointRadii() { return mPointRadii; }
     double X() { return mX; }
     double Y() { return mY; }
     double Z() { return mZ; }
     double W() { return mW; }
     const nsIntRect& Rect() { return mRect; }
-    nsAString& Characters() { return mCharacters; }
-    nsAString& CharactersExtra() { return mCharactersExtra; }
-    nsAString& Data() { return mData; }
+    nsString& Characters() { return mCharacters; }
+    nsString& CharactersExtra() { return mCharactersExtra; }
+    nsString& Data() { return mData; }
     int MetaState() { return mMetaState; }
     Modifiers DOMModifiers() const;
     bool IsAltPressed() const { return (mMetaState & AMETA_ALT_MASK) != 0; }
     bool IsShiftPressed() const { return (mMetaState & AMETA_SHIFT_MASK) != 0; }
     bool IsCtrlPressed() const { return (mMetaState & AMETA_CTRL_MASK) != 0; }
     bool IsMetaPressed() const { return (mMetaState & AMETA_META_MASK) != 0; }
     int Flags() { return mFlags; }
     int Count() { return mCount; }
--- a/widget/android/nsAppShell.cpp
+++ b/widget/android/nsAppShell.cpp
@@ -725,36 +725,35 @@ nsAppShell::LegacyGeckoEvent::Run()
     case AndroidGeckoEvent::VIEWPORT: {
         if (curEvent->Characters().Length() == 0)
             break;
 
         nsCOMPtr<nsIObserverService> obsServ =
             mozilla::services::GetObserverService();
 
         const NS_ConvertUTF16toUTF8 topic(curEvent->Characters());
-        const nsPromiseFlatString& data = PromiseFlatString(curEvent->CharactersExtra());
 
-        obsServ->NotifyObservers(nullptr, topic.get(), data.get());
+        obsServ->NotifyObservers(nullptr, topic.get(), curEvent->CharactersExtra().get());
         break;
     }
 
     case AndroidGeckoEvent::TELEMETRY_UI_SESSION_STOP: {
         if (!nsAppShell::Get()->mBrowserApp)
             break;
         if (curEvent->Characters().Length() == 0)
             break;
 
         nsCOMPtr<nsIUITelemetryObserver> obs;
         nsAppShell::Get()->mBrowserApp->GetUITelemetryObserver(getter_AddRefs(obs));
         if (!obs)
             break;
 
         obs->StopSession(
-                nsString(curEvent->Characters()).get(),
-                nsString(curEvent->CharactersExtra()).get(),
+                curEvent->Characters().get(),
+                curEvent->CharactersExtra().get(),
                 curEvent->Time()
                 );
         break;
     }
 
     case AndroidGeckoEvent::TELEMETRY_UI_SESSION_START: {
         if (!nsAppShell::Get()->mBrowserApp)
             break;
@@ -762,17 +761,17 @@ nsAppShell::LegacyGeckoEvent::Run()
             break;
 
         nsCOMPtr<nsIUITelemetryObserver> obs;
         nsAppShell::Get()->mBrowserApp->GetUITelemetryObserver(getter_AddRefs(obs));
         if (!obs)
             break;
 
         obs->StartSession(
-                nsString(curEvent->Characters()).get(),
+                curEvent->Characters().get(),
                 curEvent->Time()
                 );
         break;
     }
 
     case AndroidGeckoEvent::TELEMETRY_UI_EVENT: {
         if (!nsAppShell::Get()->mBrowserApp)
             break;
@@ -780,20 +779,20 @@ nsAppShell::LegacyGeckoEvent::Run()
             break;
 
         nsCOMPtr<nsIUITelemetryObserver> obs;
         nsAppShell::Get()->mBrowserApp->GetUITelemetryObserver(getter_AddRefs(obs));
         if (!obs)
             break;
 
         obs->AddEvent(
-                nsString(curEvent->Data()).get(),
-                nsString(curEvent->Characters()).get(),
+                curEvent->Data().get(),
+                curEvent->Characters().get(),
                 curEvent->Time(),
-                nsString(curEvent->CharactersExtra()).get()
+                curEvent->CharactersExtra().get()
                 );
         break;
     }
 
     case AndroidGeckoEvent::LOAD_URI: {
         nsCOMPtr<nsICommandLineRunner> cmdline
             (do_CreateInstance("@mozilla.org/toolkit/command-line;1"));
         if (!cmdline)
@@ -824,17 +823,17 @@ nsAppShell::LegacyGeckoEvent::Run()
     }
 
     case AndroidGeckoEvent::VISITED: {
 #ifdef MOZ_ANDROID_HISTORY
         nsCOMPtr<IHistory> history = services::GetHistoryService();
         nsCOMPtr<nsIURI> visitedURI;
         if (history &&
             NS_SUCCEEDED(NS_NewURI(getter_AddRefs(visitedURI),
-                                   nsString(curEvent->Characters())))) {
+                                   curEvent->Characters()))) {
             history->NotifyVisited(visitedURI);
         }
 #endif
         break;
     }
 
     case AndroidGeckoEvent::NETWORK_CHANGED: {
         hal::NotifyNetworkChange(hal::NetworkInformation(curEvent->ConnectionType(),
@@ -879,17 +878,17 @@ nsAppShell::LegacyGeckoEvent::Run()
 
     case AndroidGeckoEvent::CALL_OBSERVER:
     {
         nsCOMPtr<nsIObserver> observer;
         nsAppShell::Get()->mObserversHash.Get(curEvent->Characters(), getter_AddRefs(observer));
 
         if (observer) {
             observer->Observe(nullptr, NS_ConvertUTF16toUTF8(curEvent->CharactersExtra()).get(),
-                              nsString(curEvent->Data()).get());
+                              curEvent->Data().get());
         } else {
             ALOG("Call_Observer event: Observer was not found!");
         }
 
         break;
     }
 
     case AndroidGeckoEvent::REMOVE_OBSERVER:
@@ -913,17 +912,17 @@ nsAppShell::LegacyGeckoEvent::Run()
         break;
 
     case AndroidGeckoEvent::NETWORK_LINK_CHANGE:
     {
         nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService();
         if (os) {
             os->NotifyObservers(nullptr,
                                 NS_NETWORK_LINK_TOPIC,
-                                nsString(curEvent->Characters()).get());
+                                curEvent->Characters().get());
         }
         break;
     }
 
     case AndroidGeckoEvent::TELEMETRY_HISTOGRAM_ADD:
         // If the extras field is not empty then this is a keyed histogram.
         if (!curEvent->CharactersExtra().IsVoid()) {
             Telemetry::Accumulate(NS_ConvertUTF16toUTF8(curEvent->Characters()).get(),