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

Side by Side Diff: Source/wtf/text/StringHash.h

Issue 1152163005: Speed up case folding for 8-bit strings (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added a unit test 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
« no previous file with comments | « no previous file | Source/wtf/text/StringImpl.h » ('j') | 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) 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved 2 * Copyright (C) 2006, 2007, 2008, 2012, 2013 Apple Inc. All rights reserved
3 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 3 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 return (a == b) || equal(a.impl(), b.impl()); 119 return (a == b) || equal(a.impl(), b.impl());
120 } 120 }
121 121
122 static const bool safeToCompareToEmptyOrDeleted = false; 122 static const bool safeToCompareToEmptyOrDeleted = false;
123 123
124 private: 124 private:
125 // Private so no one uses this in the belief that it will return the 125 // Private so no one uses this in the belief that it will return the
126 // correctly-folded code point in all cases (see comment below). 126 // correctly-folded code point in all cases (see comment below).
127 template<typename T> static inline UChar foldCase(T ch) 127 template<typename T> static inline UChar foldCase(T ch)
128 { 128 {
129 if (IsSameType<T, LChar>::value)
130 return StringImpl::latin1CaseFoldTable[ch];
129 // It's possible for WTF::Unicode::foldCase() to return a 32-bit 131 // It's possible for WTF::Unicode::foldCase() to return a 32-bit
130 // value that's not representable as a UChar. However, since this 132 // value that's not representable as a UChar. However, since this
131 // is rare and deterministic, and the result of this is merely used 133 // is rare and deterministic, and the result of this is merely used
132 // for hashing, go ahead and clamp the value. 134 // for hashing, go ahead and clamp the value.
133 return static_cast<UChar>(WTF::Unicode::foldCase(ch)); 135 return static_cast<UChar>(WTF::Unicode::foldCase(ch));
134 } 136 }
135 }; 137 };
136 138
137 // This hash can be used in cases where the key is a hash of a string, but w e don't 139 // This hash can be used in cases where the key is a hash of a string, but w e don't
138 // want to store the string. It's not really specific to string hashing, but all our 140 // want to store the string. It's not really specific to string hashing, but all our
(...skipping 15 matching lines...) Expand all
154 } 156 }
155 }; 157 };
156 158
157 } 159 }
158 160
159 using WTF::AlreadyHashed; 161 using WTF::AlreadyHashed;
160 using WTF::CaseFoldingHash; 162 using WTF::CaseFoldingHash;
161 using WTF::StringHash; 163 using WTF::StringHash;
162 164
163 #endif 165 #endif
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/text/StringImpl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698