Bug 1441404, return early when appending null string to a text fragment, r=baku
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Tue, 27 Mar 2018 19:24:53 +0300
changeset 410208 7d9e36d70c3e9c7e750362b77c1b7f81b3f05c56
parent 410207 2c9044fa02f939ef1f2dae0384666845e5b5098d
child 410209 38646fa333aadb4aad63e24589465aa9d8ab3e3d
push id101420
push useropettay@mozilla.com
push dateTue, 27 Mar 2018 16:34:20 +0000
treeherdermozilla-inbound@7d9e36d70c3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1441404
milestone61.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 1441404, return early when appending null string to a text fragment, r=baku
dom/base/nsTextFragment.cpp
--- a/dom/base/nsTextFragment.cpp
+++ b/dom/base/nsTextFragment.cpp
@@ -357,16 +357,20 @@ nsTextFragment::CopyTo(char16_t *aDest, 
     }
   }
 }
 
 bool
 nsTextFragment::Append(const char16_t* aBuffer, uint32_t aLength,
                        bool aUpdateBidi, bool aForce2b)
 {
+  if (!aLength) {
+    return true;
+  }
+
   // This is a common case because some callsites create a textnode
   // with a value by creating the node and then calling AppendData.
   if (mState.mLength == 0) {
     return SetTo(aBuffer, aLength, aUpdateBidi, aForce2b);
   }
 
   // Should we optimize for aData.Length() == 0?