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

Side by Side Diff: Source/core/html/parser/HTMLIdentifier.cpp

Issue 46803005: Get rid of unused global variables in HTMLIdentifier.cpp (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 1 month 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 | « Source/core/html/parser/HTMLIdentifier.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) 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 return 0; 69 return 0;
70 // It's possible to have hash collisions between arbitrary strings and 70 // It's possible to have hash collisions between arbitrary strings and
71 // known identifiers (e.g. "bvvfg" collides with "script"). 71 // known identifiers (e.g. "bvvfg" collides with "script").
72 // However ASSERTs in addNames() guard against there ever being collisions 72 // However ASSERTs in addNames() guard against there ever being collisions
73 // between known identifiers. 73 // between known identifiers.
74 if (!equal(it->value, characters, length)) 74 if (!equal(it->value, characters, length))
75 return 0; 75 return 0;
76 return it->value; 76 return it->value;
77 } 77 }
78 78
79 const unsigned kHTMLNamesIndexOffset = 0;
80 const unsigned kHTMLAttrsIndexOffset = 1000;
81 COMPILE_ASSERT(kHTMLAttrsIndexOffset > HTMLTagsCount, kHTMLAttrsIndexOffset_shou ld_be_larger_than_HTMLTagsCount);
82
83 const String& HTMLIdentifier::asString() const 79 const String& HTMLIdentifier::asString() const
84 { 80 {
85 ASSERT(isMainThread()); 81 ASSERT(isMainThread());
86 return m_string; 82 return m_string;
87 } 83 }
88 84
89 const StringImpl* HTMLIdentifier::asStringImpl() const 85 const StringImpl* HTMLIdentifier::asStringImpl() const
90 { 86 {
91 return m_string.impl(); 87 return m_string.impl();
92 } 88 }
93 89
94 void HTMLIdentifier::addNames(const QualifiedName* const* names, unsigned namesC ount, unsigned indexOffset) 90 void HTMLIdentifier::addNames(const QualifiedName* const* names, unsigned namesC ount)
95 { 91 {
96 IdentifierTable& table = identifierTable(); 92 IdentifierTable& table = identifierTable();
97 for (unsigned i = 0; i < namesCount; ++i) { 93 for (unsigned i = 0; i < namesCount; ++i) {
98 StringImpl* name = names[i]->localName().impl(); 94 StringImpl* name = names[i]->localName().impl();
99 unsigned hash = name->hash(); 95 unsigned hash = name->hash();
100 IdentifierTable::AddResult addResult = table.add(hash, name); 96 IdentifierTable::AddResult addResult = table.add(hash, name);
101 maxNameLength = std::max(maxNameLength, name->length()); 97 maxNameLength = std::max(maxNameLength, name->length());
102 // Ensure we're using the same hashing algorithm to get and set. 98 // 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); 99 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. 100 // We expect some hash collisions, but only for identical strings.
105 // Since all of these names are AtomicStrings pointers should be equal. 101 // Since all of these names are AtomicStrings pointers should be equal.
106 // Note: If you hit this ASSERT, then we had a hash collision among 102 // Note: If you hit this ASSERT, then we had a hash collision among
107 // HTMLNames strings, and we need to re-design how we use this hash! 103 // HTMLNames strings, and we need to re-design how we use this hash!
108 ASSERT_UNUSED(addResult, !addResult.isNewEntry || name == addResult.iter ator->value); 104 ASSERT_UNUSED(addResult, !addResult.isNewEntry || name == addResult.iter ator->value);
109 } 105 }
110 } 106 }
111 107
112 void HTMLIdentifier::init() 108 void HTMLIdentifier::init()
113 { 109 {
114 ASSERT(isMainThread()); // Not technically necessary, but this is our curren t expected usage. 110 ASSERT(isMainThread()); // Not technically necessary, but this is our curren t expected usage.
115 static bool isInitialized = false; 111 static bool isInitialized = false;
116 if (isInitialized) 112 if (isInitialized)
117 return; 113 return;
118 isInitialized = true; 114 isInitialized = true;
119 115
120 // FIXME: We should atomize small whitespace (\n, \n\n, etc.) 116 // FIXME: We should atomize small whitespace (\n, \n\n, etc.)
121 addNames(getHTMLTags(), HTMLTagsCount, kHTMLNamesIndexOffset); 117 addNames(getHTMLTags(), HTMLTagsCount);
122 addNames(getHTMLAttrs(), HTMLAttrsCount, kHTMLAttrsIndexOffset); 118 addNames(getHTMLAttrs(), HTMLAttrsCount);
123 } 119 }
124 120
125 } 121 }
OLDNEW
« no previous file with comments | « Source/core/html/parser/HTMLIdentifier.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698