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

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

Issue 1390033003: Remove StringImpl::reallocate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 310
311 // Allocate a single buffer large enough to contain the StringImpl 311 // Allocate a single buffer large enough to contain the StringImpl
312 // struct as well as the data which it contains. This removes one 312 // struct as well as the data which it contains. This removes one
313 // heap allocation from this call. 313 // heap allocation from this call.
314 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc ationSize<UChar>(length))); 314 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferMalloc(alloc ationSize<UChar>(length)));
315 315
316 data = reinterpret_cast<UChar*>(string + 1); 316 data = reinterpret_cast<UChar*>(string + 1);
317 return adoptRef(new (string) StringImpl(length)); 317 return adoptRef(new (string) StringImpl(length));
318 } 318 }
319 319
320 PassRefPtr<StringImpl> StringImpl::reallocate(PassRefPtr<StringImpl> originalStr ing, unsigned length)
321 {
322 ASSERT(originalString->hasOneRef());
323
324 if (!length)
325 return empty();
326
327 bool is8Bit = originalString->is8Bit();
328 // Same as createUninitialized() except here we use realloc.
329 size_t size = is8Bit ? allocationSize<LChar>(length) : allocationSize<UChar> (length);
330 originalString->~StringImpl();
331 StringImpl* string = static_cast<StringImpl*>(Partitions::bufferRealloc(orig inalString.leakRef(), size));
332 if (is8Bit)
333 return adoptRef(new (string) StringImpl(length, Force8BitConstructor));
334 return adoptRef(new (string) StringImpl(length));
335 }
336
337 static StaticStringsTable& staticStrings() 320 static StaticStringsTable& staticStrings()
338 { 321 {
339 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ()); 322 DEFINE_STATIC_LOCAL(StaticStringsTable, staticStrings, ());
340 return staticStrings; 323 return staticStrings;
341 } 324 }
342 325
343 #if ENABLE(ASSERT) 326 #if ENABLE(ASSERT)
344 static bool s_allowCreationOfStaticStrings = true; 327 static bool s_allowCreationOfStaticStrings = true;
345 #endif 328 #endif
346 329
(...skipping 1779 matching lines...) Expand 10 before | Expand all | Expand 10 after
2126 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2127 // TODO(rob.buis) implement upper-casing rules for lt 2110 // TODO(rob.buis) implement upper-casing rules for lt
2128 // like in StringImpl::upper(locale). 2111 // like in StringImpl::upper(locale).
2129 } 2112 }
2130 } 2113 }
2131 2114
2132 return toUpper(c); 2115 return toUpper(c);
2133 } 2116 }
2134 2117
2135 } // namespace WTF 2118 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698