Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2878)

Unified Diff: Source/wtf/text/WTFString.h

Issue 21274008: Remove ASCIILiteral optimization from StringImpl (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/wtf/text/StringImpl.cpp ('k') | Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/wtf/text/WTFString.h
diff --git a/Source/wtf/text/WTFString.h b/Source/wtf/text/WTFString.h
index f06fe127643d35a7d7b4cca0b8ece3eca9b03ac0..122703b02f5c394dd37dacd582eaafdef25f2b92 100644
--- a/Source/wtf/text/WTFString.h
+++ b/Source/wtf/text/WTFString.h
@@ -74,8 +74,6 @@ WTF_EXPORT float charactersToFloat(const UChar*, size_t, bool* ok = 0);
WTF_EXPORT float charactersToFloat(const LChar*, size_t, size_t& parsedLength);
WTF_EXPORT float charactersToFloat(const UChar*, size_t, size_t& parsedLength);
-class ASCIILiteral;
-
enum TrailingZerosTruncatingPolicy {
KeepTrailingZeros,
TruncateTrailingZeros
@@ -84,6 +82,16 @@ enum TrailingZerosTruncatingPolicy {
template<bool isSpecialCharacter(UChar), typename CharacterType>
bool isAllSpecialCharacters(const CharacterType*, size_t);
+// FIXME: Remove this class once all callers are gone.
+class ASCIILiteral {
+public:
+ explicit ASCIILiteral(const char* characters) : m_characters(characters) { }
+ operator const char*() { return m_characters; }
+
+private:
+ const char* m_characters;
+};
+
class WTF_EXPORT String {
public:
// Construct a null string, distinguishable from an empty string.
@@ -118,14 +126,10 @@ public:
String(PassRefPtr<StringImpl> impl) : m_impl(impl) { }
String(RefPtr<StringImpl> impl) : m_impl(impl) { }
- // Construct a string from a constant string literal.
- String(ASCIILiteral characters);
-
- // Construct a string from a constant string literal.
- // This constructor is the "big" version, as it put the length in the function call and generate bigger code.
+ // FIXME: Remove this API once all callers are gone.
enum ConstructFromLiteralTag { ConstructFromLiteral };
- template<unsigned charactersCount>
- String(const char (&characters)[charactersCount], ConstructFromLiteralTag) : m_impl(StringImpl::createFromLiteral<charactersCount>(characters)) { }
+ String(const char* characters, ConstructFromLiteralTag) : m_impl(StringImpl::create(reinterpret_cast<const LChar*>(characters))) { }
+ String(ASCIILiteral literal) : m_impl(StringImpl::create(reinterpret_cast<const LChar*>(static_cast<const char*>(literal)))) { }
#if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
// We have to declare the copy constructor and copy assignment operator as well, otherwise
@@ -690,15 +694,6 @@ template<> struct DefaultHash<String> {
template <> struct VectorTraits<String> : SimpleClassVectorTraits { };
-class ASCIILiteral {
-public:
- explicit ASCIILiteral(const char* characters) : m_characters(characters) { }
- operator const char*() { return m_characters; }
-
-private:
- const char* m_characters;
-};
-
// Shared global empty string.
WTF_EXPORT const String& emptyString();
« no previous file with comments | « Source/wtf/text/StringImpl.cpp ('k') | Source/wtf/text/WTFString.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698