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

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

Issue 387313002: Shrink isValidNameNonASCII by using U16_NEXT only once. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
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 unified diff | Download patch
« no previous file with comments | « no previous file | 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) 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 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 4087 matching lines...) Expand 10 before | Expand all | Expand 10 after
4098 for (unsigned i = 1; i < length; ++i) { 4098 for (unsigned i = 1; i < length; ++i) {
4099 if (!isValidNamePart(characters[i])) 4099 if (!isValidNamePart(characters[i]))
4100 return false; 4100 return false;
4101 } 4101 }
4102 4102
4103 return true; 4103 return true;
4104 } 4104 }
4105 4105
4106 static bool isValidNameNonASCII(const UChar* characters, unsigned length) 4106 static bool isValidNameNonASCII(const UChar* characters, unsigned length)
4107 { 4107 {
4108 unsigned i = 0; 4108 for (unsigned i = 0; i < length;) {
fs 2014/09/04 12:01:18 Some might be alarmed by a for lacking an update e
4109 4109 bool first = i == 0;
fs 2014/09/04 12:01:18 I suppose this could also be: bool nameStart = tr
4110 UChar32 c; 4110 UChar32 c;
4111 U16_NEXT(characters, i, length, c) 4111 U16_NEXT(characters, i, length, c); // Increments i.
4112 if (!isValidNameStart(c)) 4112 if (first ? !isValidNameStart(c) : !isValidNamePart(c))
4113 return false;
4114
4115 while (i < length) {
4116 U16_NEXT(characters, i, length, c)
4117 if (!isValidNamePart(c))
4118 return false; 4113 return false;
4119 } 4114 }
4120 4115
4121 return true; 4116 return true;
4122 } 4117 }
4123 4118
4124 template<typename CharType> 4119 template<typename CharType>
4125 static inline bool isValidNameASCII(const CharType* characters, unsigned length) 4120 static inline bool isValidNameASCII(const CharType* characters, unsigned length)
4126 { 4121 {
4127 CharType c = characters[0]; 4122 CharType c = characters[0];
(...skipping 1707 matching lines...) Expand 10 before | Expand all | Expand 10 after
5835 visitor->trace(m_compositorPendingAnimations); 5830 visitor->trace(m_compositorPendingAnimations);
5836 visitor->trace(m_contextDocument); 5831 visitor->trace(m_contextDocument);
5837 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this); 5832 visitor->registerWeakMembers<Document, &Document::clearWeakMembers>(this);
5838 DocumentSupplementable::trace(visitor); 5833 DocumentSupplementable::trace(visitor);
5839 TreeScope::trace(visitor); 5834 TreeScope::trace(visitor);
5840 ContainerNode::trace(visitor); 5835 ContainerNode::trace(visitor);
5841 ExecutionContext::trace(visitor); 5836 ExecutionContext::trace(visitor);
5842 } 5837 }
5843 5838
5844 } // namespace WebCore 5839 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698