Bug 1344498 - Add fallible StripWhitespace r=njn
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 23 Mar 2017 12:52:31 +0100
changeset 349368 533f7d421ef64569130ddbaf69425b702a837d69
parent 349367 9becd55242c177056d602cbde548b67e1559966c
child 349369 47fbdd127336308711e081faa3a88446f94872ae
push id31550
push usercbook@mozilla.com
push dateFri, 24 Mar 2017 13:22:27 +0000
treeherdermozilla-central@473e0b201761 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn
bugs1344498
milestone55.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 1344498 - Add fallible StripWhitespace r=njn MozReview-Commit-ID: 8UOTEBlFxfO
xpcom/string/nsTString.h
xpcom/string/nsTStringObsolete.cpp
--- a/xpcom/string/nsTString.h
+++ b/xpcom/string/nsTString.h
@@ -367,22 +367,24 @@ public:
    *  characters found in aSet from this string.
    *
    *  @param  aSet -- characters to be cut from this
    */
 #ifdef CharT_is_PRUnichar
   using nsTSubstring_CharT::StripChars;
 #endif
   void StripChars(const char* aSet);
+  bool StripChars(const char* aSet, const fallible_t&);
 
 
   /**
    *  This method strips whitespace throughout the string.
    */
   void StripWhitespace();
+  bool StripWhitespace(const fallible_t&);
 
 
   /**
    *  swaps occurence of 1 string for another
    */
 
   void ReplaceChar(char_type aOldChar, char_type aNewChar);
   void ReplaceChar(const char* aSet, char_type aNewChar);
--- a/xpcom/string/nsTStringObsolete.cpp
+++ b/xpcom/string/nsTStringObsolete.cpp
@@ -402,22 +402,38 @@ void
 nsTString_CharT::StripChars( const char* aSet )
 {
   if (!EnsureMutable())
     AllocFailed(mLength);
 
   mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
 }
 
+bool
+nsTString_CharT::StripChars( const char* aSet, const fallible_t& )
+{
+  if (!EnsureMutable()) {
+    return false;
+  }
+
+  mLength = nsBufferRoutines<CharT>::strip_chars(mData, mLength, aSet);
+  return true;
+}
+
 void
 nsTString_CharT::StripWhitespace()
 {
   StripChars(kWhitespace);
 }
 
+bool
+nsTString_CharT::StripWhitespace(const fallible_t& aFallible)
+{
+  return StripChars(kWhitespace, aFallible);
+}
 
 /**
  * nsTString::ReplaceChar,ReplaceSubstring
  */
 
 void
 nsTString_CharT::ReplaceChar( char_type aOldChar, char_type aNewChar )
 {