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/core/html/parser/AtomicHTMLToken.h

Issue 2556043002: Avoid WTF::Vector::at() and operator[] in core/html. (Closed)
Patch Set: _ Created 4 years 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) 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }; 215 };
216 216
217 inline void AtomicHTMLToken::initializeAttributes( 217 inline void AtomicHTMLToken::initializeAttributes(
218 const HTMLToken::AttributeList& attributes) { 218 const HTMLToken::AttributeList& attributes) {
219 size_t size = attributes.size(); 219 size_t size = attributes.size();
220 if (!size) 220 if (!size)
221 return; 221 return;
222 222
223 m_attributes.clear(); 223 m_attributes.clear();
224 m_attributes.reserveInitialCapacity(size); 224 m_attributes.reserveInitialCapacity(size);
225 for (size_t i = 0; i < size; ++i) { 225 for (const auto& attribute : attributes) {
226 const HTMLToken::Attribute& attribute = attributes[i];
227 if (attribute.nameAsVector().isEmpty()) 226 if (attribute.nameAsVector().isEmpty())
228 continue; 227 continue;
229 228
230 attribute.nameRange().checkValid(); 229 attribute.nameRange().checkValid();
231 attribute.valueRange().checkValid(); 230 attribute.valueRange().checkValid();
232 231
233 AtomicString value(attribute.value8BitIfNecessary()); 232 AtomicString value(attribute.value8BitIfNecessary());
234 const QualifiedName& name = nameForAttribute(attribute); 233 const QualifiedName& name = nameForAttribute(attribute);
235 // FIXME: This is N^2 for the number of attributes. 234 // FIXME: This is N^2 for the number of attributes.
236 if (!findAttributeInVector(m_attributes, name)) 235 if (!findAttributeInVector(m_attributes, name))
237 m_attributes.append(Attribute(name, value)); 236 m_attributes.append(Attribute(name, value));
238 } 237 }
239 } 238 }
240 239
241 } // namespace blink 240 } // namespace blink
242 241
243 #endif 242 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698