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

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringView.cpp

Issue 2024373002: Replace CSSParserString with StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "wtf/text/StringView.h" 5 #include "wtf/text/StringView.h"
6 6
7 namespace WTF { 7 namespace WTF {
8 8
9 StringView::StringView(const UChar* chars, unsigned length) 9 StringView::StringView(const UChar* chars, unsigned length)
10 : m_length(length) 10 : m_length(length)
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 if (a.is8Bit()) { 44 if (a.is8Bit()) {
45 if (b.is8Bit()) 45 if (b.is8Bit())
46 return equal(a.characters8(), b.characters8(), a.length()); 46 return equal(a.characters8(), b.characters8(), a.length());
47 return equal(a.characters8(), b.characters16(), a.length()); 47 return equal(a.characters8(), b.characters16(), a.length());
48 } 48 }
49 if (b.is8Bit()) 49 if (b.is8Bit())
50 return equal(a.characters16(), b.characters8(), a.length()); 50 return equal(a.characters16(), b.characters8(), a.length());
51 return equal(a.characters16(), b.characters16(), a.length()); 51 return equal(a.characters16(), b.characters16(), a.length());
52 } 52 }
53 53
54 bool equalIgnoringASCIICase(StringView a, StringView b)
55 {
56 if (a.length() != b.length())
57 return false;
58 if (a.isEmpty() || b.isEmpty())
Timothy Loh 2016/06/01 05:51:32 How about: if (a.isEmpty()) return true; Or
esprehn 2016/06/01 06:19:04 I see that the method in StringImpl.h does accept
59 return a.isEmpty() == b.isEmpty();
60 if (a.is8Bit()) {
61 if (b.is8Bit())
62 return equalIgnoringASCIICase(a.characters8(), b.characters8(), a.le ngth());
63 return equalIgnoringASCIICase(a.characters8(), b.characters16(), a.lengt h());
64 }
65 if (b.is8Bit())
66 return equalIgnoringASCIICase(a.characters16(), b.characters8(), a.lengt h());
67 return equalIgnoringASCIICase(a.characters16(), b.characters16(), a.length() );
68 }
69
54 } // namespace WTF 70 } // namespace WTF
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698