Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
| 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
| 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) | 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) |
| 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All |
| 6 * rights reserved. | 6 * rights reserved. |
| 7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 8 * | 8 * |
| 9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
| 10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 47 #include "wtf/ThreadingPrimitives.h" | 47 #include "wtf/ThreadingPrimitives.h" |
| 48 #include <unistd.h> | 48 #include <unistd.h> |
| 49 #endif | 49 #endif |
| 50 | 50 |
| 51 using namespace std; | 51 using namespace std; |
| 52 | 52 |
| 53 namespace WTF { | 53 namespace WTF { |
| 54 | 54 |
| 55 using namespace Unicode; | 55 using namespace Unicode; |
| 56 | 56 |
| 57 #if !DCHECK_IS_ON() | |
| 57 static_assert(sizeof(StringImpl) == 3 * sizeof(int), | 58 static_assert(sizeof(StringImpl) == 3 * sizeof(int), |
| 58 "StringImpl should stay small"); | 59 "StringImpl should stay small"); |
| 60 #endif | |
| 59 | 61 |
| 60 #ifdef STRING_STATS | 62 #ifdef STRING_STATS |
| 61 | 63 |
| 62 static Mutex& statsMutex() { | 64 static Mutex& statsMutex() { |
| 63 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); | 65 DEFINE_STATIC_LOCAL(Mutex, mutex, ()); |
| 64 return mutex; | 66 return mutex; |
| 65 } | 67 } |
| 66 | 68 |
| 67 static HashSet<void*>& liveStrings() { | 69 static HashSet<void*>& liveStrings() { |
| 68 // Notice that we can't use HashSet<StringImpl*> because then HashSet would | 70 // Notice that we can't use HashSet<StringImpl*> because then HashSet would |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 317 return true; | 319 return true; |
| 318 // AtomicStrings are not safe to send between threads as ~StringImpl() | 320 // AtomicStrings are not safe to send between threads as ~StringImpl() |
| 319 // will try to remove them from the wrong AtomicStringTable. | 321 // will try to remove them from the wrong AtomicStringTable. |
| 320 if (isAtomic()) | 322 if (isAtomic()) |
| 321 return false; | 323 return false; |
| 322 if (hasOneRef()) | 324 if (hasOneRef()) |
| 323 return true; | 325 return true; |
| 324 return false; | 326 return false; |
| 325 } | 327 } |
| 326 | 328 |
| 329 #if DCHECK_IS_ON() | |
| 330 std::string StringImpl::asciiForDebugging() const { | |
| 331 const unsigned kMaxCheckLength = 64; | |
| 332 std::string debugString; | |
| 333 for (unsigned i = 0; i < length() && i < kMaxCheckLength; ++i) { | |
| 334 UChar c = (*this)[i]; | |
| 335 debugString.push_back(isASCIIPrintable(c) ? c : '?'); | |
| 336 } | |
| 337 return debugString; | |
|
esprehn
2017/01/11 22:34:01
This function can be:
CString ascii = left(64).as
Charlie Harrison
2017/01/12 16:42:30
Ah right, for some reason I was concerned with pul
Charlie Harrison
2017/01/12 22:50:08
Actually, left is a function of String, so it woul
| |
| 338 } | |
| 339 #endif | |
| 340 | |
| 327 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, | 341 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, |
| 328 LChar*& data) { | 342 LChar*& data) { |
| 329 if (!length) { | 343 if (!length) { |
| 330 data = 0; | 344 data = 0; |
| 331 return empty(); | 345 return empty(); |
| 332 } | 346 } |
| 333 | 347 |
| 334 // Allocate a single buffer large enough to contain the StringImpl | 348 // Allocate a single buffer large enough to contain the StringImpl |
| 335 // struct as well as the data which it contains. This removes one | 349 // struct as well as the data which it contains. This removes one |
| 336 // heap allocation from this call. | 350 // heap allocation from this call. |
| (...skipping 1840 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2177 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2191 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
| 2178 // TODO(rob.buis) implement upper-casing rules for lt | 2192 // TODO(rob.buis) implement upper-casing rules for lt |
| 2179 // like in StringImpl::upper(locale). | 2193 // like in StringImpl::upper(locale). |
| 2180 } | 2194 } |
| 2181 } | 2195 } |
| 2182 | 2196 |
| 2183 return toUpper(c); | 2197 return toUpper(c); |
| 2184 } | 2198 } |
| 2185 | 2199 |
| 2186 } // namespace WTF | 2200 } // namespace WTF |
| OLD | NEW |