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 r ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. |
| 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
| 7 * | 7 * |
| 8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
| 9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
| 10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 336 { | 336 { |
| 337 ASSERT(isMainThread()); | 337 ASSERT(isMainThread()); |
| 338 | 338 |
| 339 #if ENABLE(ASSERT) | 339 #if ENABLE(ASSERT) |
| 340 s_allowCreationOfStaticStrings = false; | 340 s_allowCreationOfStaticStrings = false; |
| 341 #endif | 341 #endif |
| 342 } | 342 } |
| 343 | 343 |
| 344 unsigned StringImpl::m_highestStaticStringLength = 0; | 344 unsigned StringImpl::m_highestStaticStringLength = 0; |
| 345 | 345 |
| 346 StringImpl* StringImpl::createPreallocatedStatic(void* buffer, unsigned length, unsigned hash) | |
| 347 { | |
| 348 ASSERT(s_allowCreationOfStaticStrings); | |
| 349 ASSERT(buffer); | |
| 350 ASSERT(length); | |
| 351 | |
| 352 StringImpl* impl = static_cast<StringImpl*>(buffer); | |
| 353 | |
| 354 StaticStringsTable::const_iterator it = staticStrings().find(hash); | |
| 355 if (it != staticStrings().end()) { | |
| 356 ASSERT(!memcmp(reinterpret_cast<LChar*>(impl + 1), it->value + 1, length * sizeof(LChar))); | |
| 357 return it->value; | |
|
kouhei (in TOK)
2015/10/21 01:08:17
Are we ever going to reach here? If not, ASSERT?
tzik
2015/10/28 14:33:31
We do actually reach here due to duplicated static
| |
| 358 } | |
| 359 | |
| 360 impl = new (impl) StringImpl(length, hash, StaticString); | |
| 361 #if ENABLE(ASSERT) | |
| 362 impl->assertHashIsCorrect(); | |
| 363 #endif | |
| 364 | |
| 365 ASSERT(isMainThread()); | |
| 366 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); | |
| 367 staticStrings().add(hash, impl); | |
| 368 WTF_ANNOTATE_BENIGN_RACE(impl, | |
| 369 "Benign race on the reference counter of a static string created by Stri ngImpl::createStatic"); | |
|
tkent
2015/10/21 03:19:34
createStatic -> createPreallocatedStatic?
tzik
2015/10/28 14:33:31
Done.
| |
| 370 | |
| 371 return impl; | |
| 372 } | |
| 373 | |
| 346 StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign ed hash) | 374 StringImpl* StringImpl::createStatic(const char* string, unsigned length, unsign ed hash) |
| 347 { | 375 { |
| 348 ASSERT(s_allowCreationOfStaticStrings); | 376 ASSERT(s_allowCreationOfStaticStrings); |
| 349 ASSERT(string); | 377 ASSERT(string); |
| 350 ASSERT(length); | 378 ASSERT(length); |
| 351 | 379 |
| 352 StaticStringsTable::const_iterator it = staticStrings().find(hash); | 380 StaticStringsTable::const_iterator it = staticStrings().find(hash); |
| 353 if (it != staticStrings().end()) { | 381 if (it != staticStrings().end()) { |
| 354 ASSERT(!memcmp(string, it->value + 1, length * sizeof(LChar))); | 382 ASSERT(!memcmp(string, it->value + 1, length * sizeof(LChar))); |
| 355 return it->value; | 383 return it->value; |
| (...skipping 1753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2137 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
| 2110 // TODO(rob.buis) implement upper-casing rules for lt | 2138 // TODO(rob.buis) implement upper-casing rules for lt |
| 2111 // like in StringImpl::upper(locale). | 2139 // like in StringImpl::upper(locale). |
| 2112 } | 2140 } |
| 2113 } | 2141 } |
| 2114 | 2142 |
| 2115 return toUpper(c); | 2143 return toUpper(c); |
| 2116 } | 2144 } |
| 2117 | 2145 |
| 2118 } // namespace WTF | 2146 } // namespace WTF |
| OLD | NEW |