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

Side by Side Diff: Source/core/inspector/DOMEditor.cpp

Issue 183763033: Avoid calling hasAttribute() and then getAttribute() for performance (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase Created 6 years, 9 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/html/HTMLAnchorElement.cpp ('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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 : InspectorHistory::Action("SetAttribute") 168 : InspectorHistory::Action("SetAttribute")
169 , m_element(element) 169 , m_element(element)
170 , m_name(name) 170 , m_name(name)
171 , m_value(value) 171 , m_value(value)
172 , m_hadAttribute(false) 172 , m_hadAttribute(false)
173 { 173 {
174 } 174 }
175 175
176 virtual bool perform(ExceptionState& exceptionState) OVERRIDE 176 virtual bool perform(ExceptionState& exceptionState) OVERRIDE
177 { 177 {
178 m_hadAttribute = m_element->hasAttribute(m_name); 178 const AtomicString& value = m_element->getAttribute(m_name);
179 m_hadAttribute = !value.isNull();
179 if (m_hadAttribute) 180 if (m_hadAttribute)
180 m_oldValue = m_element->getAttribute(m_name); 181 m_oldValue = value;
181 return redo(exceptionState); 182 return redo(exceptionState);
182 } 183 }
183 184
184 virtual bool undo(ExceptionState& exceptionState) OVERRIDE 185 virtual bool undo(ExceptionState& exceptionState) OVERRIDE
185 { 186 {
186 if (m_hadAttribute) 187 if (m_hadAttribute)
187 m_element->setAttribute(m_name, m_oldValue, exceptionState); 188 m_element->setAttribute(m_name, m_oldValue, exceptionState);
188 else 189 else
189 m_element->removeAttribute(m_name); 190 m_element->removeAttribute(m_name);
190 return true; 191 return true;
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString * errorString) 453 bool DOMEditor::replaceWholeText(Text* textNode, const String& text, ErrorString * errorString)
453 { 454 {
454 TrackExceptionState exceptionState; 455 TrackExceptionState exceptionState;
455 bool result = replaceWholeText(textNode, text, exceptionState); 456 bool result = replaceWholeText(textNode, text, exceptionState);
456 populateErrorString(exceptionState, errorString); 457 populateErrorString(exceptionState, errorString);
457 return result; 458 return result;
458 } 459 }
459 460
460 } // namespace WebCore 461 } // namespace WebCore
461 462
OLDNEW
« no previous file with comments | « Source/core/html/HTMLAnchorElement.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698