Bug 1344498 - Add fallible StripWhitespace r=njn a=gchang
authorValentin Gosu <valentin.gosu@gmail.com>
Thu, 23 Mar 2017 12:52:31 +0100
changeset 395453 369a0d04420535e89d6fb1d6d05a11e4c1cf14f5
parent 395452 316ec3452a611f5c3bd9d400fe0cecd1db001752
child 395454 e524e3cf3a116cdcb8d2c04eb7aacac3a26d85df
push id1468
push userasasaki@mozilla.com
push dateMon, 05 Jun 2017 19:31:07 +0000
treeherdermozilla-release@0641fc6ee9d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnjn, gchang
bugs1344498
milestone54.0a2
Bug 1344498 - Add fallible StripWhitespace r=njn a=gchang 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 )
 {