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

Side by Side Diff: Source/core/dom/Node.cpp

Issue 177613003: Consistently cache ElementData::length() before loops (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix test failure Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/dom/ElementData.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. 5 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved.
6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 6 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/) 7 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmo bile.com/)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 1323 matching lines...) Expand 10 before | Expand all | Expand 10 after
1334 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt om : namespaceURIMaybeEmpty; 1334 const AtomicString& namespaceURI = namespaceURIMaybeEmpty.isEmpty() ? nullAt om : namespaceURIMaybeEmpty;
1335 1335
1336 switch (nodeType()) { 1336 switch (nodeType()) {
1337 case ELEMENT_NODE: { 1337 case ELEMENT_NODE: {
1338 const Element* elem = toElement(this); 1338 const Element* elem = toElement(this);
1339 1339
1340 if (elem->prefix().isNull()) 1340 if (elem->prefix().isNull())
1341 return elem->namespaceURI() == namespaceURI; 1341 return elem->namespaceURI() == namespaceURI;
1342 1342
1343 if (elem->hasAttributes()) { 1343 if (elem->hasAttributes()) {
1344 for (unsigned i = 0; i < elem->attributeCount(); i++) { 1344 unsigned attributeCount = elem->attributeCount();
1345 for (unsigned i = 0; i < attributeCount; ++i) {
1345 const Attribute* attr = elem->attributeItem(i); 1346 const Attribute* attr = elem->attributeItem(i);
1346 1347
1347 if (attr->localName() == xmlnsAtom) 1348 if (attr->localName() == xmlnsAtom)
1348 return attr->value() == namespaceURI; 1349 return attr->value() == namespaceURI;
1349 } 1350 }
1350 } 1351 }
1351 1352
1352 if (Element* parent = parentElement()) 1353 if (Element* parent = parentElement())
1353 return parent->isDefaultNamespace(namespaceURI); 1354 return parent->isDefaultNamespace(namespaceURI);
1354 1355
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 return nullAtom; 1420 return nullAtom;
1420 1421
1421 switch (nodeType()) { 1422 switch (nodeType()) {
1422 case ELEMENT_NODE: { 1423 case ELEMENT_NODE: {
1423 const Element *elem = toElement(this); 1424 const Element *elem = toElement(this);
1424 1425
1425 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix) 1426 if (!elem->namespaceURI().isNull() && elem->prefix() == prefix)
1426 return elem->namespaceURI(); 1427 return elem->namespaceURI();
1427 1428
1428 if (elem->hasAttributes()) { 1429 if (elem->hasAttributes()) {
1429 for (unsigned i = 0; i < elem->attributeCount(); i++) { 1430 unsigned attributeCount = elem->attributeCount();
1431 for (unsigned i = 0; i < attributeCount; ++i) {
1430 const Attribute* attr = elem->attributeItem(i); 1432 const Attribute* attr = elem->attributeItem(i);
1431 1433
1432 if (attr->prefix() == xmlnsAtom && attr->localName() == pref ix) { 1434 if (attr->prefix() == xmlnsAtom && attr->localName() == pref ix) {
1433 if (!attr->value().isEmpty()) 1435 if (!attr->value().isEmpty())
1434 return attr->value(); 1436 return attr->value();
1435 1437
1436 return nullAtom; 1438 return nullAtom;
1437 } else if (attr->localName() == xmlnsAtom && prefix.isNull() ) { 1439 } else if (attr->localName() == xmlnsAtom && prefix.isNull() ) {
1438 if (!attr->value().isEmpty()) 1440 if (!attr->value().isEmpty())
1439 return attr->value(); 1441 return attr->value();
(...skipping 1114 matching lines...) Expand 10 before | Expand all | Expand 10 after
2554 node->showTreeForThis(); 2556 node->showTreeForThis();
2555 } 2557 }
2556 2558
2557 void showNodePath(const WebCore::Node* node) 2559 void showNodePath(const WebCore::Node* node)
2558 { 2560 {
2559 if (node) 2561 if (node)
2560 node->showNodePathForThis(); 2562 node->showNodePathForThis();
2561 } 2563 }
2562 2564
2563 #endif 2565 #endif
OLDNEW
« no previous file with comments | « Source/core/dom/ElementData.cpp ('k') | Source/core/html/HTMLEmbedElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698