Title: [158490] trunk/Source/WTF
Revision
158490
Author
akl...@apple.com
Date
2013-11-02 09:59:53 -0700 (Sat, 02 Nov 2013)

Log Message

StringImpl::upper() should return PassRef.
<https://webkit.org/b/123655>

Make upper() return PassRef<StringImpl>. Spotted and removed some
ref churning in implementations.

Reviewed by Darin Adler.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (158489 => 158490)


--- trunk/Source/WTF/ChangeLog	2013-11-02 16:42:47 UTC (rev 158489)
+++ trunk/Source/WTF/ChangeLog	2013-11-02 16:59:53 UTC (rev 158490)
@@ -1,3 +1,13 @@
+2013-11-02  Andreas Kling  <akl...@apple.com>
+
+        StringImpl::upper() should return PassRef.
+        <https://webkit.org/b/123655>
+
+        Make upper() return PassRef<StringImpl>. Spotted and removed some
+        ref churning in implementations.
+
+        Reviewed by Darin Adler.
+
 2013-11-01  Alexey Proskuryakov  <a...@apple.com>
 
         Add WebCrypto AES-CBC

Modified: trunk/Source/WTF/wtf/text/StringImpl.cpp (158489 => 158490)


--- trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-11-02 16:42:47 UTC (rev 158489)
+++ trunk/Source/WTF/wtf/text/StringImpl.cpp	2013-11-02 16:59:53 UTC (rev 158490)
@@ -468,7 +468,7 @@
     return newImpl.releaseNonNull();
 }
 
-PassRefPtr<StringImpl> StringImpl::upper()
+PassRef<StringImpl> StringImpl::upper()
 {
     // This function could be optimized for no-op cases the way lower() is,
     // but in empirical testing, few actual calls to upper() are no-ops, so
@@ -497,7 +497,7 @@
 #endif
         }
         if (!(ored & ~0x7F))
-            return newImpl.release();
+            return newImpl.releaseNonNull();
 
         // Do a slower implementation for cases that include non-ASCII Latin-1 characters.
         int numberSharpSCharacters = 0;
@@ -519,7 +519,7 @@
         }
 
         if (!numberSharpSCharacters)
-            return newImpl.release();
+            return newImpl.releaseNonNull();
 
         // We have numberSSCharacters sharp-s characters, but none of the other special characters.
         newImpl = createUninitialized(m_length + numberSharpSCharacters, data8);
@@ -537,7 +537,7 @@
             }
         }
 
-        return newImpl.release();
+        return newImpl.releaseNonNull();
     }
 
 upconvert:
@@ -554,19 +554,19 @@
         data16[i] = toASCIIUpper(c);
     }
     if (!(ored & ~0x7F))
-        return newImpl.release();
+        return newImpl.releaseNonNull();
 
     // Do a slower implementation for cases that include non-ASCII characters.
     UErrorCode status = U_ZERO_ERROR;
     int32_t realLength = u_strToUpper(data16, length, source16, m_length, "", &status);
     if (U_SUCCESS(status) && realLength == length)
-        return newImpl;
+        return newImpl.releaseNonNull();
     newImpl = createUninitialized(realLength, data16);
     status = U_ZERO_ERROR;
     u_strToUpper(data16, realLength, source16, m_length, "", &status);
     if (U_FAILURE(status))
-        return this;
-    return newImpl.release();
+        return *this;
+    return newImpl.releaseNonNull();
 }
 
 static inline bool needsTurkishCasingRules(const AtomicString& localeIdentifier)
@@ -614,7 +614,7 @@
     return newString.releaseNonNull();
 }
 
-RefPtr<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier)
+PassRef<StringImpl> StringImpl::upper(const AtomicString& localeIdentifier)
 {
     // Use the more-optimized code path most of the time.
     // Assuming here that the only locale-specific lowercasing is the Turkish casing rules,
@@ -635,13 +635,13 @@
     UErrorCode status = U_ZERO_ERROR;
     int realLength = u_strToUpper(data16, length, source16, length, "tr", &status);
     if (U_SUCCESS(status) && realLength == length)
-        return newString;
+        return newString.releaseNonNull();
     newString = createUninitialized(realLength, data16);
     status = U_ZERO_ERROR;
     u_strToUpper(data16, realLength, source16, length, "tr", &status);
     if (U_FAILURE(status))
-        return this;
-    return newString.release();
+        return *this;
+    return newString.releaseNonNull();
 }
 
 PassRefPtr<StringImpl> StringImpl::fill(UChar character)

Modified: trunk/Source/WTF/wtf/text/StringImpl.h (158489 => 158490)


--- trunk/Source/WTF/wtf/text/StringImpl.h	2013-11-02 16:42:47 UTC (rev 158489)
+++ trunk/Source/WTF/wtf/text/StringImpl.h	2013-11-02 16:59:53 UTC (rev 158490)
@@ -689,9 +689,9 @@
     float toFloat(bool* ok = 0);
 
     WTF_EXPORT_STRING_API PassRef<StringImpl> lower();
-    WTF_EXPORT_STRING_API PassRefPtr<StringImpl> upper();
+    WTF_EXPORT_STRING_API PassRef<StringImpl> upper();
     WTF_EXPORT_STRING_API PassRef<StringImpl> lower(const AtomicString& localeIdentifier);
-    WTF_EXPORT_STRING_API RefPtr<StringImpl> upper(const AtomicString& localeIdentifier);
+    WTF_EXPORT_STRING_API PassRef<StringImpl> upper(const AtomicString& localeIdentifier);
 
     WTF_EXPORT_STRING_API PassRefPtr<StringImpl> fill(UChar);
     // FIXME: Do we need fill(char) or can we just do the right thing if UChar is ASCII?
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to