Bug 913953 - Part ab: Remove unused WriteInto function; r=ehsan
authorMs2ger <ms2ger@gmail.com>
Tue, 10 Sep 2013 09:03:37 +0200
changeset 146249 6c061b718a6de40463866b1be41a80629cafdbab
parent 146248 6d3ca3b813539bbd93dfca68a003e8b2ec393775
child 146250 e73983f4a10802a5f2e637422d40b69d743ba43b
push id25250
push userMs2ger@gmail.com
push dateTue, 10 Sep 2013 07:05:27 +0000
treeherdermozilla-central@be1053dc223b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs913953
milestone26.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 913953 - Part ab: Remove unused WriteInto function; r=ehsan
ipc/chromium/src/base/string_util.h
--- a/ipc/chromium/src/base/string_util.h
+++ b/ipc/chromium/src/base/string_util.h
@@ -213,39 +213,16 @@ std::wstring StringPrintf(const wchar_t*
 const std::string& SStringPrintf(std::string* dst, const char* format, ...);
 const std::wstring& SStringPrintf(std::wstring* dst,
                                   const wchar_t* format, ...);
 
 // Append result to a supplied string
 void StringAppendF(std::string* dst, const char* format, ...);
 void StringAppendF(std::wstring* dst, const wchar_t* format, ...);
 
-// This is mpcomplete's pattern for saving a string copy when dealing with
-// a function that writes results into a wchar_t[] and wanting the result to
-// end up in a std::wstring.  It ensures that the std::wstring's internal
-// buffer has enough room to store the characters to be written into it, and
-// sets its .length() attribute to the right value.
-//
-// The reserve() call allocates the memory required to hold the string
-// plus a terminating null.  This is done because resize() isn't
-// guaranteed to reserve space for the null.  The resize() call is
-// simply the only way to change the string's 'length' member.
-//
-// XXX-performance: the call to wide.resize() takes linear time, since it fills
-// the string's buffer with nulls.  I call it to change the length of the
-// string (needed because writing directly to the buffer doesn't do this).
-// Perhaps there's a constant-time way to change the string's length.
-template <class string_type>
-inline typename string_type::value_type* WriteInto(string_type* str,
-                                                   size_t length_with_null) {
-  str->reserve(length_with_null);
-  str->resize(length_with_null - 1);
-  return &((*str)[0]);
-}
-
 //-----------------------------------------------------------------------------
 
 // Splits |str| into a vector of strings delimited by |s|. Append the results
 // into |r| as they appear. If several instances of |s| are contiguous, or if
 // |str| begins with or ends with |s|, then an empty string is inserted.
 //
 // Every substring is trimmed of any leading or trailing white space.
 void SplitString(const std::wstring& str,