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

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

Issue 1363653006: Reserve capacity for static strings HashMap. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed the deduced string length (exclude NULL terminator) 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
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 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 390
391 ASSERT(isMainThread()); 391 ASSERT(isMainThread());
392 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length); 392 m_highestStaticStringLength = std::max(m_highestStaticStringLength, length);
393 staticStrings().add(hash, impl); 393 staticStrings().add(hash, impl);
394 WTF_ANNOTATE_BENIGN_RACE(impl, 394 WTF_ANNOTATE_BENIGN_RACE(impl,
395 "Benign race on the reference counter of a static string created by Stri ngImpl::createStatic"); 395 "Benign race on the reference counter of a static string created by Stri ngImpl::createStatic");
396 396
397 return impl; 397 return impl;
398 } 398 }
399 399
400 void StringImpl::reserveStaticStringsCapacityForSize(unsigned size)
401 {
402 ASSERT(s_allowCreationOfStaticStrings);
403 staticStrings().reserveCapacityForSize(size);
404 }
405
400 PassRefPtr<StringImpl> StringImpl::create(const UChar* characters, unsigned leng th) 406 PassRefPtr<StringImpl> StringImpl::create(const UChar* characters, unsigned leng th)
401 { 407 {
402 if (!characters || !length) 408 if (!characters || !length)
403 return empty(); 409 return empty();
404 410
405 UChar* data; 411 UChar* data;
406 RefPtr<StringImpl> string = createUninitialized(length, data); 412 RefPtr<StringImpl> string = createUninitialized(length, data);
407 memcpy(data, characters, length * sizeof(UChar)); 413 memcpy(data, characters, length * sizeof(UChar));
408 return string.release(); 414 return string.release();
409 } 415 }
(...skipping 1710 matching lines...) Expand 10 before | Expand all | Expand 10 after
2120 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2126 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2121 // TODO(rob.buis) implement upper-casing rules for lt 2127 // TODO(rob.buis) implement upper-casing rules for lt
2122 // like in StringImpl::upper(locale). 2128 // like in StringImpl::upper(locale).
2123 } 2129 }
2124 } 2130 }
2125 2131
2126 return toUpper(c); 2132 return toUpper(c);
2127 } 2133 }
2128 2134
2129 } // namespace WTF 2135 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/StringStatics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698