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

Side by Side Diff: Source/wtf/text/StringImpl.cpp

Issue 1189593003: Rename Partitions::getRenderingPartition() -> getLayoutPartition() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/wtf/text/CString.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 double overheadPercent = (double)totalOverhead / (double)totalDataBytes * 10 0; 255 double overheadPercent = (double)totalOverhead / (double)totalDataBytes * 10 0;
256 dataLogF(" StringImpl overheader: %8u (%5.2f%%)\n", totalOverhead, o verheadPercent); 256 dataLogF(" StringImpl overheader: %8u (%5.2f%%)\n", totalOverhead, o verheadPercent);
257 257
258 internal::callOnMainThread(&printLiveStringStats, nullptr); 258 internal::callOnMainThread(&printLiveStringStats, nullptr);
259 } 259 }
260 #endif 260 #endif
261 261
262 void* StringImpl::operator new(size_t size) 262 void* StringImpl::operator new(size_t size)
263 { 263 {
264 ASSERT(size == sizeof(StringImpl)); 264 ASSERT(size == sizeof(StringImpl));
265 return partitionAllocGeneric(Partitions::getBufferPartition(), size); 265 return partitionAllocGeneric(Partitions::bufferPartition(), size);
266 } 266 }
267 267
268 void StringImpl::operator delete(void* ptr) 268 void StringImpl::operator delete(void* ptr)
269 { 269 {
270 partitionFreeGeneric(Partitions::getBufferPartition(), ptr); 270 partitionFreeGeneric(Partitions::bufferPartition(), ptr);
271 } 271 }
272 272
273 inline StringImpl::~StringImpl() 273 inline StringImpl::~StringImpl()
274 { 274 {
275 ASSERT(!isStatic()); 275 ASSERT(!isStatic());
276 276
277 STRING_STATS_REMOVE_STRING(this); 277 STRING_STATS_REMOVE_STRING(this);
278 278
279 if (isAtomic()) 279 if (isAtomic())
280 AtomicString::remove(this); 280 AtomicString::remove(this);
281 } 281 }
282 282
283 void StringImpl::destroyIfNotStatic() 283 void StringImpl::destroyIfNotStatic()
284 { 284 {
285 if (!isStatic()) 285 if (!isStatic())
286 delete this; 286 delete this;
287 } 287 }
288 288
289 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data) 289 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, LChar*& data)
290 { 290 {
291 if (!length) { 291 if (!length) {
292 data = 0; 292 data = 0;
293 return empty(); 293 return empty();
294 } 294 }
295 295
296 // Allocate a single buffer large enough to contain the StringImpl 296 // Allocate a single buffer large enough to contain the StringImpl
297 // struct as well as the data which it contains. This removes one 297 // struct as well as the data which it contains. This removes one
298 // heap allocation from this call. 298 // heap allocation from this call.
299 StringImpl* string = static_cast<StringImpl*>(partitionAllocGeneric(Partitio ns::getBufferPartition(), allocationSize<LChar>(length))); 299 StringImpl* string = static_cast<StringImpl*>(partitionAllocGeneric(Partitio ns::bufferPartition(), allocationSize<LChar>(length)));
300 300
301 data = reinterpret_cast<LChar*>(string + 1); 301 data = reinterpret_cast<LChar*>(string + 1);
302 return adoptRef(new (string) StringImpl(length, Force8BitConstructor)); 302 return adoptRef(new (string) StringImpl(length, Force8BitConstructor));
303 } 303 }
304 304
305 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*& data) 305 PassRefPtr<StringImpl> StringImpl::createUninitialized(unsigned length, UChar*& data)
306 { 306 {
307 if (!length) { 307 if (!length) {
308 data = 0; 308 data = 0;
309 return empty(); 309 return empty();
310 } 310 }
311 311
312 // Allocate a single buffer large enough to contain the StringImpl 312 // Allocate a single buffer large enough to contain the StringImpl
313 // struct as well as the data which it contains. This removes one 313 // struct as well as the data which it contains. This removes one
314 // heap allocation from this call. 314 // heap allocation from this call.
315 StringImpl* string = static_cast<StringImpl*>(partitionAllocGeneric(Partitio ns::getBufferPartition(), allocationSize<UChar>(length))); 315 StringImpl* string = static_cast<StringImpl*>(partitionAllocGeneric(Partitio ns::bufferPartition(), allocationSize<UChar>(length)));
316 316
317 data = reinterpret_cast<UChar*>(string + 1); 317 data = reinterpret_cast<UChar*>(string + 1);
318 return adoptRef(new (string) StringImpl(length)); 318 return adoptRef(new (string) StringImpl(length));
319 } 319 }
320 320
321 PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalStr ing, unsigned length) 321 PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalStr ing, unsigned length)
322 { 322 {
323 ASSERT(originalString->hasOneRef()); 323 ASSERT(originalString->hasOneRef());
324 324
325 if (!length) 325 if (!length)
326 return empty(); 326 return empty();
327 327
328 bool is8Bit = originalString->is8Bit(); 328 bool is8Bit = originalString->is8Bit();
329 // Same as createUninitialized() except here we use realloc. 329 // Same as createUninitialized() except here we use realloc.
330 size_t size = is8Bit ? allocationSize<LChar>(length) : allocationSize<UChar> (length); 330 size_t size = is8Bit ? allocationSize<LChar>(length) : allocationSize<UChar> (length);
331 originalString->~StringImpl(); 331 originalString->~StringImpl();
332 StringImpl* string = static_cast<StringImpl*>(partitionReallocGeneric(Partit ions::getBufferPartition(), originalString.leakRef(), size)); 332 StringImpl* string = static_cast<StringImpl*>(partitionReallocGeneric(Partit ions::bufferPartition(), originalString.leakRef(), size));
333 if (is8Bit) 333 if (is8Bit)
334 return adoptRef(new (string) StringImpl(length, Force8BitConstructor)); 334 return adoptRef(new (string) StringImpl(length, Force8BitConstructor));
335 return adoptRef(new (string) StringImpl(length)); 335 return adoptRef(new (string) StringImpl(length));
336 } 336 }
337 337
338 static StaticStringsTable& staticStrings() 338 static StaticStringsTable& staticStrings()
339 { 339 {
340 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); 340 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ());
341 return staticStrings; 341 return staticStrings;
342 } 342 }
(...skipping 30 matching lines...) Expand all
373 return it->value; 373 return it->value;
374 } 374 }
375 375
376 // Allocate a single buffer large enough to contain the StringImpl 376 // Allocate a single buffer large enough to contain the StringImpl
377 // struct as well as the data which it contains. This removes one 377 // struct as well as the data which it contains. This removes one
378 // heap allocation from this call. 378 // heap allocation from this call.
379 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str ingImpl)) / sizeof(LChar))); 379 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof(Str ingImpl)) / sizeof(LChar)));
380 size_t size = sizeof(StringImpl) + length * sizeof(LChar); 380 size_t size = sizeof(StringImpl) + length * sizeof(LChar);
381 381
382 WTF_ANNOTATE_SCOPED_MEMORY_LEAK; 382 WTF_ANNOTATE_SCOPED_MEMORY_LEAK;
383 StringImpl* impl = static_cast<StringImpl*>(partitionAllocGeneric(Partitions ::getBufferPartition(), size)); 383 StringImpl* impl = static_cast<StringImpl*>(partitionAllocGeneric(Partitions ::bufferPartition(), size));
384 384
385 LChar* data = reinterpret_cast<LChar*>(impl + 1); 385 LChar* data = reinterpret_cast<LChar*>(impl + 1);
386 impl = new (impl) StringImpl(length, hash, StaticString); 386 impl = new (impl) StringImpl(length, hash, StaticString);
387 memcpy(data, string, length * sizeof(LChar)); 387 memcpy(data, string, length * sizeof(LChar));
388 #if ENABLE(ASSERT) 388 #if ENABLE(ASSERT)
389 impl->assertHashIsCorrect(); 389 impl->assertHashIsCorrect();
390 #endif 390 #endif
391 391
392 ASSERT(isMainThread()); 392 ASSERT(isMainThread());
393 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); 393 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length);
(...skipping 1726 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2120 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2121 // TODO(rob.buis) implement upper-casing rules for lt 2121 // TODO(rob.buis) implement upper-casing rules for lt
2122 // like in StringImpl::upper(locale). 2122 // like in StringImpl::upper(locale).
2123 } 2123 }
2124 } 2124 }
2125 2125
2126 return toUpper(c); 2126 return toUpper(c);
2127 } 2127 }
2128 2128
2129 } // namespace WTF 2129 } // namespace WTF
OLDNEW
« no previous file with comments | « Source/wtf/text/CString.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698