OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 Google, 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 { | 84 { |
85 ASSERT(isMainThread()); | 85 ASSERT(isMainThread()); |
86 return m_string; | 86 return m_string; |
87 } | 87 } |
88 | 88 |
89 const StringImpl* HTMLIdentifier::asStringImpl() const | 89 const StringImpl* HTMLIdentifier::asStringImpl() const |
90 { | 90 { |
91 return m_string.impl(); | 91 return m_string.impl(); |
92 } | 92 } |
93 | 93 |
94 void HTMLIdentifier::addNames(QualifiedName** names, unsigned namesCount, unsign
ed indexOffset) | 94 void HTMLIdentifier::addNames(const QualifiedName* const* names, unsigned namesC
ount, unsigned indexOffset) |
95 { | 95 { |
96 IdentifierTable& table = identifierTable(); | 96 IdentifierTable& table = identifierTable(); |
97 for (unsigned i = 0; i < namesCount; ++i) { | 97 for (unsigned i = 0; i < namesCount; ++i) { |
98 StringImpl* name = names[i]->localName().impl(); | 98 StringImpl* name = names[i]->localName().impl(); |
99 unsigned hash = name->hash(); | 99 unsigned hash = name->hash(); |
100 IdentifierTable::AddResult addResult = table.add(hash, name); | 100 IdentifierTable::AddResult addResult = table.add(hash, name); |
101 maxNameLength = std::max(maxNameLength, name->length()); | 101 maxNameLength = std::max(maxNameLength, name->length()); |
102 // Ensure we're using the same hashing algorithm to get and set. | 102 // Ensure we're using the same hashing algorithm to get and set. |
103 ASSERT_UNUSED(addResult, !addResult.isNewEntry || HTMLIdentifier::findIf
Known(String(name).charactersWithNullTermination().data(), name->length()) == na
me); | 103 ASSERT_UNUSED(addResult, !addResult.isNewEntry || HTMLIdentifier::findIf
Known(String(name).charactersWithNullTermination().data(), name->length()) == na
me); |
104 // We expect some hash collisions, but only for identical strings. | 104 // We expect some hash collisions, but only for identical strings. |
(...skipping 11 matching lines...) Expand all Loading... |
116 if (isInitialized) | 116 if (isInitialized) |
117 return; | 117 return; |
118 isInitialized = true; | 118 isInitialized = true; |
119 | 119 |
120 // FIXME: We should atomize small whitespace (\n, \n\n, etc.) | 120 // FIXME: We should atomize small whitespace (\n, \n\n, etc.) |
121 addNames(getHTMLTags(), HTMLTagsCount, kHTMLNamesIndexOffset); | 121 addNames(getHTMLTags(), HTMLTagsCount, kHTMLNamesIndexOffset); |
122 addNames(getHTMLAttrs(), HTMLAttrsCount, kHTMLAttrsIndexOffset); | 122 addNames(getHTMLAttrs(), HTMLAttrsCount, kHTMLAttrsIndexOffset); |
123 } | 123 } |
124 | 124 |
125 } | 125 } |
OLD | NEW |