]> granicus.if.org Git - icu/commitdiff
ICU-12140 Pass StringPiece by value, internally.
authorFredrik Roubert <roubert@google.com>
Thu, 4 Aug 2016 17:40:53 +0000 (17:40 +0000)
committerFredrik Roubert <roubert@google.com>
Thu, 4 Aug 2016 17:40:53 +0000 (17:40 +0000)
R=markus.icu@gmail.com

Review URL: https://codereview.appspot.com/305000043 .

X-SVN-Rev: 39024

13 files changed:
icu4c/source/common/bytestriebuilder.cpp
icu4c/source/common/charstr.cpp
icu4c/source/common/charstr.h
icu4c/source/common/unicode/stringpiece.h
icu4c/source/common/unicode/unistr.h
icu4c/source/common/unistr.cpp
icu4c/source/common/uts46.cpp
icu4c/source/i18n/compactdecimalformat.cpp
icu4c/source/i18n/decimfmtimpl.cpp
icu4c/source/i18n/decimfmtimpl.h
icu4c/source/i18n/digitlst.cpp
icu4c/source/i18n/digitlst.h
icu4c/source/i18n/unicode/compactdecimalformat.h

index e8ad3a562d0a9e05b0283f26c94eb88141a9c1a6..71fea8923cba8f89b5b417f26704b50e0fe7da88 100644 (file)
@@ -37,7 +37,7 @@ class BytesTrieElement : public UMemory {
 public:
     // Use compiler's default constructor, initializes nothing.
 
-    void setTo(const StringPiece &s, int32_t val, CharString &strings, UErrorCode &errorCode);
+    void setTo(StringPiece s, int32_t val, CharString &strings, UErrorCode &errorCode);
 
     StringPiece getString(const CharString &strings) const {
         int32_t offset=stringOffset;
@@ -88,7 +88,7 @@ private:
 };
 
 void
-BytesTrieElement::setTo(const StringPiece &s, int32_t val,
+BytesTrieElement::setTo(StringPiece s, int32_t val,
                         CharString &strings, UErrorCode &errorCode) {
     if(U_FAILURE(errorCode)) {
         return;
index be2c6c34a621560a5cb0b0849ade492a8a511206..c792181378ec0b1baad1000f31569e260d5c2f16 100644 (file)
@@ -146,7 +146,7 @@ UBool CharString::ensureCapacity(int32_t capacity,
     return TRUE;
 }
 
-CharString &CharString::appendPathPart(const StringPiece &s, UErrorCode &errorCode) {
+CharString &CharString::appendPathPart(StringPiece s, UErrorCode &errorCode) {
     if(U_FAILURE(errorCode)) {
         return *this;
     }
index 766a1a4dce4bb804950b0ea4642aec614f74f953..9758c5c542b3f03d25106d7ccae7671bcc55c654 100644 (file)
@@ -41,7 +41,7 @@ template class U_COMMON_API MaybeStackArray<char, 40>;
 class U_COMMON_API CharString : public UMemory {
 public:
     CharString() : len(0) { buffer[0]=0; }
-    CharString(const StringPiece &s, UErrorCode &errorCode) : len(0) {
+    CharString(StringPiece s, UErrorCode &errorCode) : len(0) {
         buffer[0]=0;
         append(s, errorCode);
     }
@@ -78,7 +78,7 @@ public:
     CharString &truncate(int32_t newLength);
 
     CharString &append(char c, UErrorCode &errorCode);
-    CharString &append(const StringPiece &s, UErrorCode &errorCode) {
+    CharString &append(StringPiece s, UErrorCode &errorCode) {
         return append(s.data(), s.length(), errorCode);
     }
     CharString &append(const CharString &s, UErrorCode &errorCode) {
@@ -117,7 +117,7 @@ public:
      * First appends a U_FILE_SEP_CHAR if necessary.
      * Does nothing if s is empty.
      */
-    CharString &appendPathPart(const StringPiece &s, UErrorCode &errorCode);
+    CharString &appendPathPart(StringPiece s, UErrorCode &errorCode);
 
     /**
      * Appends a U_FILE_SEP_CHAR if this string is not empty
index c06fbfb9282d1b0129d81e6460b7d8dcea5f1660..5e40d4aca9b758eaa3c03e212339ab45b72bfd52 100644 (file)
@@ -42,9 +42,9 @@ U_NAMESPACE_BEGIN
  * in a "const char*" or a "string" wherever a "StringPiece" is
  * expected.
  *
- * Functions or methods may use const StringPiece& parameters to accept either
- * a "const char*" or a "string" value that will be implicitly converted to
- * StringPiece.
+ * Functions or methods may use StringPiece parameters to accept either a
+ * "const char*" or a "string" value that will be implicitly converted to a
+ * StringPiece.
  *
  * Systematic usage of StringPiece is encouraged as it will reduce unnecessary
  * conversions from "const char*" to "string" and back again.
index c09ec58475f3a9faf5fd260dd1ff868b4948b83e..257f72e3608fd83abef55aafd15f3b8388ac1ea6 100644 (file)
@@ -3394,7 +3394,7 @@ protected:
 
 private:
   // For char* constructors. Could be made public.
-  UnicodeString &setToUTF8(const StringPiece &utf8);
+  UnicodeString &setToUTF8(StringPiece utf8);
   // For extract(char*).
   // We could make a toUTF8(target, capacity, errorCode) public but not
   // this version: New API will be cleaner if we make callers create substrings
index 1f4ae11b6a9dfeadae19a0fb23ce9e00da171597..2004a8ce420bdbb13e37ddb865e70dab8a3cdd33 100644 (file)
@@ -1301,7 +1301,7 @@ UnicodeString::setTo(UChar *buffer,
   return *this;
 }
 
-UnicodeString &UnicodeString::setToUTF8(const StringPiece &utf8) {
+UnicodeString &UnicodeString::setToUTF8(StringPiece utf8) {
   unBogus();
   int32_t length = utf8.length();
   int32_t capacity;
index 30963a8bcc9c1a501b3ca42b97e7cec957687e93..7e9707712bd8886a5d0d3458e2acebc9114c2561 100644 (file)
@@ -156,7 +156,7 @@ private:
             IDNAInfo &info, UErrorCode &errorCode) const;
 
     void
-    processUTF8(const StringPiece &src,
+    processUTF8(StringPiece src,
                 UBool isLabel, UBool toASCII,
                 ByteSink &dest,
                 IDNAInfo &info, UErrorCode &errorCode) const;
@@ -403,7 +403,7 @@ UTS46::process(const UnicodeString &src,
 }
 
 void
-UTS46::processUTF8(const StringPiece &src,
+UTS46::processUTF8(StringPiece src,
                    UBool isLabel, UBool toASCII,
                    ByteSink &dest,
                    IDNAInfo &info, UErrorCode &errorCode) const {
index ea943f3b94a3bb0f10c104cce023fd151ff81c19..385b3a513f263254323b31d5080871a261463745 100644 (file)
@@ -353,7 +353,7 @@ CompactDecimalFormat::format(
 
 UnicodeString&
 CompactDecimalFormat::format(
-    const StringPiece& /* number */,
+    StringPiece /* number */,
     UnicodeString& appendTo,
     FieldPositionIterator* /* posIter */,
     UErrorCode& status) const {
index b22a4d4911feb80d7edb8a6a8c4d51ba1727b934..1218023e2bf6d81235cde9d3e3068cfd464b4ab4 100644 (file)
@@ -427,7 +427,7 @@ DecimalFormatImpl::format(
 
 UnicodeString &
 DecimalFormatImpl::format(
-        const StringPiece &number,
+        StringPiece number,
         UnicodeString &appendTo,
         FieldPositionIterator *posIter,
         UErrorCode &status) const {
index 4c0a94a353ca6c373e116349aa02f920d70d7568..82f154edbd3557335ad9458a66beb0d716431ed5 100644 (file)
@@ -219,7 +219,7 @@ UnicodeString &format(
         FieldPositionIterator *posIter,
         UErrorCode &status) const;
 UnicodeString &format(
-        const StringPiece &number,
+        StringPiece number,
         UnicodeString &appendTo,
         FieldPositionIterator *posIter,
         UErrorCode &status) const;
index f5105a9c3175f112131c896ae6dc4e7e1c0cc6d8..32fb9c40bca93de3b1404f265412e4701e0f2944 100644 (file)
@@ -736,7 +736,7 @@ DigitList::set(int64_t source)
  * be acceptable for a public API.
  */
 void
-DigitList::set(const StringPiece &source, UErrorCode &status, uint32_t /*fastpathBits*/) {
+DigitList::set(StringPiece source, UErrorCode &status, uint32_t /*fastpathBits*/) {
     if (U_FAILURE(status)) {
         return;
     }
index 094b6cfae2ead1a30aafb1fd22b80a213704fb6a..0e781c021fde1b6ff454892111f86b1af9b27ba0 100644 (file)
@@ -269,7 +269,7 @@ public:
      * @param source The value to be set.  The string must be nul-terminated.
      * @param fastpathBits special flags for fast parsing
      */
-    void set(const StringPiece &source, UErrorCode &status, uint32_t fastpathBits = 0);
+    void set(StringPiece source, UErrorCode &status, uint32_t fastpathBits = 0);
 
     /**
      * Multiply    this = this * arg
index a1261617624822b557029dfbf434bdd6f1a03f15..800c3132938d258d7fb900c9ab43fec8be3ee016 100644 (file)
@@ -276,7 +276,7 @@ public:
      * @return          Reference to 'appendTo' parameter.
      * @internal
      */
-    virtual UnicodeString& format(const StringPiece &number,
+    virtual UnicodeString& format(StringPiece number,
                                   UnicodeString& appendTo,
                                   FieldPositionIterator* posIter,
                                   UErrorCode& status) const;