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

Unified Diff: Source/core/dom/Node.cpp

Issue 415243003: Drop slower Node::hasID() / Node::hasClass() methods (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/rendering/RenderTreeAsText.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Node.cpp
diff --git a/Source/core/dom/Node.cpp b/Source/core/dom/Node.cpp
index d413a591b5b1828239c0d50fcc274f9b5ba56794..715cedf7c0813486da9fcb8af0a7f767c7bb8aa6 100644
--- a/Source/core/dom/Node.cpp
+++ b/Source/core/dom/Node.cpp
@@ -1698,20 +1698,23 @@ String Node::debugName() const
StringBuilder name;
name.append(nodeName());
- if (hasID()) {
- name.appendLiteral(" id=\'");
- name.append(toElement(this)->getIdAttribute());
- name.append('\'');
- }
-
- if (hasClass()) {
- name.appendLiteral(" class=\'");
- for (size_t i = 0; i < toElement(this)->classNames().size(); ++i) {
- if (i > 0)
- name.append(' ');
- name.append(toElement(this)->classNames()[i]);
+ if (isElementNode()) {
+ const Element& thisElement = toElement(*this);
+ if (thisElement.hasID()) {
+ name.appendLiteral(" id=\'");
+ name.append(thisElement.getIdAttribute());
+ name.append('\'');
+ }
+
+ if (thisElement.hasClass()) {
+ name.appendLiteral(" class=\'");
+ for (size_t i = 0; i < thisElement.classNames().size(); ++i) {
+ if (i > 0)
+ name.append(' ');
+ name.append(thisElement.classNames()[i]);
+ }
+ name.append('\'');
}
- name.append('\'');
}
return name.toString();
« no previous file with comments | « Source/core/dom/Node.h ('k') | Source/core/rendering/RenderTreeAsText.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698