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

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 2636083002: WTF: Put String::show()'s definition into the WTF namespace. (Closed)
Patch Set: Created 3 years, 11 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 | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/wtf/text/WTFString.cpp
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.cpp b/third_party/WebKit/Source/wtf/text/WTFString.cpp
index 3b04de8a5bbb13ec6794d1160c3411bd11b323ec..0cfe47326d65f40620f44f709acac7a528ad8d3e 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFString.cpp
@@ -42,6 +42,31 @@ namespace WTF {
using namespace Unicode;
+namespace {
+
+Vector<char> asciiDebug(StringImpl* impl) {
+ if (!impl)
+ return asciiDebug(String("[null]").impl());
+
+ Vector<char> buffer;
+ for (unsigned i = 0; i < impl->length(); ++i) {
+ UChar ch = (*impl)[i];
+ if (isASCIIPrintable(ch)) {
+ if (ch == '\\')
+ buffer.push_back('\\');
+ buffer.push_back(static_cast<char>(ch));
+ } else {
+ buffer.push_back('\\');
+ buffer.push_back('u');
+ appendUnsignedAsHexFixedSize(ch, buffer, 4);
+ }
+ }
+ buffer.push_back('\0');
+ return buffer;
+}
+
+} // namespace
+
// Construct a string with UTF-16 data.
String::String(const UChar* characters, unsigned length)
: m_impl(characters ? StringImpl::create(characters, length) : nullptr) {}
@@ -811,46 +836,10 @@ std::ostream& operator<<(std::ostream& out, const String& string) {
return out << '"';
}
-} // namespace WTF
-
#ifndef NDEBUG
-// For use in the debugger
-String* string(const char*);
-Vector<char> asciiDebug(StringImpl*);
-Vector<char> asciiDebug(String&);
-
void String::show() const {
dataLogF("%s\n", asciiDebug(impl()).data());
}
-
-String* string(const char* s) {
- // leaks memory!
- return new String(s);
-}
-
-Vector<char> asciiDebug(StringImpl* impl) {
- if (!impl)
- return asciiDebug(String("[null]").impl());
-
- Vector<char> buffer;
- for (unsigned i = 0; i < impl->length(); ++i) {
- UChar ch = (*impl)[i];
- if (isASCIIPrintable(ch)) {
- if (ch == '\\')
- buffer.push_back('\\');
- buffer.push_back(static_cast<char>(ch));
- } else {
- buffer.push_back('\\');
- buffer.push_back('u');
- appendUnsignedAsHexFixedSize(ch, buffer, 4);
- }
- }
- buffer.push_back('\0');
- return buffer;
-}
-
-Vector<char> asciiDebug(String& string) {
- return asciiDebug(string.impl());
-}
-
#endif
+
+} // namespace WTF
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698