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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringStatics.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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.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) 2010 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2010 Apple Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 } 72 }
73 73
74 void AtomicString::init() 74 void AtomicString::init()
75 { 75 {
76 ASSERT(isMainThread()); 76 ASSERT(isMainThread());
77 77
78 new (NotNull, (void*)&nullAtom) AtomicString; 78 new (NotNull, (void*)&nullAtom) AtomicString;
79 new (NotNull, (void*)&emptyAtom) AtomicString(""); 79 new (NotNull, (void*)&emptyAtom) AtomicString("");
80 } 80 }
81 81
82 template<unsigned charactersCount>
83 PassRefPtr<StringImpl> addStaticASCIILiteral(const char (&characters)[characters Count])
84 {
85 unsigned length = charactersCount - 1;
86 unsigned hash = StringHasher::computeHashAndMaskTop8Bits(reinterpret_cast<co nst LChar*>(characters), length);
87 return adoptRef(StringImpl::createStatic(characters, length, hash));
88 }
89
82 void StringStatics::init() 90 void StringStatics::init()
83 { 91 {
84 ASSERT(isMainThread()); 92 ASSERT(isMainThread());
85 93
86 // FIXME: These should be allocated at compile time. 94 // FIXME: These should be allocated at compile time.
87 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFro mLiteral); 95 new (NotNull, (void*)&starAtom) AtomicString("*", AtomicString::ConstructFro mLiteral);
88 new (NotNull, (void*)&xmlAtom) AtomicString("xml", AtomicString::ConstructFr omLiteral); 96 new (NotNull, (void*)&xmlAtom) AtomicString(addStaticASCIILiteral("xml"));
89 new (NotNull, (void*)&xmlnsAtom) AtomicString("xmlns", AtomicString::Constru ctFromLiteral); 97 new (NotNull, (void*)&xmlnsAtom) AtomicString(addStaticASCIILiteral("xmlns") );
90 new (NotNull, (void*)&xlinkAtom) AtomicString("xlink", AtomicString::Constru ctFromLiteral); 98 new (NotNull, (void*)&xlinkAtom) AtomicString(addStaticASCIILiteral("xlink") );
91 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:"); 99 new (NotNull, (void*)&xmlnsWithColon) String("xmlns:");
92 } 100 }
93 101
94 } 102 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698