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

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.h

Issue 2225173002: Use StringView for String::find. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing null check. Created 4 years, 4 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 | « third_party/WebKit/Source/wtf/text/StringImpl.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 * (C) 1999 Lars Knoll (knoll@kde.org) 2 * (C) 1999 Lars Knoll (knoll@kde.org)
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 static String number(unsigned long); 162 static String number(unsigned long);
163 static String number(long long); 163 static String number(long long);
164 static String number(unsigned long long); 164 static String number(unsigned long long);
165 165
166 static String number(double, unsigned precision = 6); 166 static String number(double, unsigned precision = 6);
167 167
168 // Number to String conversion following the ECMAScript definition. 168 // Number to String conversion following the ECMAScript definition.
169 static String numberToStringECMAScript(double); 169 static String numberToStringECMAScript(double);
170 static String numberToStringFixedWidth(double, unsigned decimalPlaces); 170 static String numberToStringFixedWidth(double, unsigned decimalPlaces);
171 171
172 // Find a single character or string, also with match function & latin1 172 // Find characters.
173 // forms.
174 size_t find(UChar c, unsigned start = 0) const 173 size_t find(UChar c, unsigned start = 0) const
175 { return m_impl ? m_impl->find(c, start) : kNotFound; } 174 { return m_impl ? m_impl->find(c, start) : kNotFound; }
176 size_t find(LChar c, unsigned start = 0) const 175 size_t find(LChar c, unsigned start = 0) const
177 { return m_impl ? m_impl->find(c, start) : kNotFound; } 176 { return m_impl ? m_impl->find(c, start) : kNotFound; }
178 size_t find(char c, unsigned start = 0) const { return find(static_cast<LCha r>(c), start); } 177 size_t find(char c, unsigned start = 0) const { return find(static_cast<LCha r>(c), start); }
179
180 size_t find(const String& str) const
181 { return m_impl ? m_impl->find(str.impl()) : kNotFound; }
182 size_t find(const String& str, unsigned start) const
183 { return m_impl ? m_impl->find(str.impl(), start) : kNotFound; }
184
185 size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) con st 178 size_t find(CharacterMatchFunctionPtr matchFunction, unsigned start = 0) con st
186 { return m_impl ? m_impl->find(matchFunction, start) : kNotFound; } 179 { return m_impl ? m_impl->find(matchFunction, start) : kNotFound; }
187 size_t find(const LChar* str, unsigned start = 0) const 180
188 { return m_impl ? m_impl->find(str, start) : kNotFound; } 181 // Find substrings.
182 size_t find(const StringView& value, unsigned start = 0, TextCaseSensitivity caseSensitivity = TextCaseSensitive) const
183 { return m_impl ? DISPATCH_CASE_OP(caseSensitivity, m_impl->find, (value , start)) : kNotFound; }
189 184
190 // Find the last instance of a single character or string. 185 // Find the last instance of a single character or string.
191 size_t reverseFind(UChar c, unsigned start = UINT_MAX) const 186 size_t reverseFind(UChar c, unsigned start = UINT_MAX) const
192 { return m_impl ? m_impl->reverseFind(c, start) : kNotFound; } 187 { return m_impl ? m_impl->reverseFind(c, start) : kNotFound; }
193 size_t reverseFind(const String& str, unsigned start = UINT_MAX) const 188 size_t reverseFind(const String& str, unsigned start = UINT_MAX) const
194 { return m_impl ? m_impl->reverseFind(str.impl(), start) : kNotFound; } 189 { return m_impl ? m_impl->reverseFind(str.impl(), start) : kNotFound; }
195 190
196 // Case insensitive string matching. 191 // Case insensitive string matching.
197 size_t findIgnoringCase(const LChar* str, unsigned start = 0) const 192 size_t findIgnoringCase(const LChar* str, unsigned start = 0) const
198 { return m_impl ? m_impl->findIgnoringCase(str, start) : kNotFound; } 193 { return m_impl ? m_impl->findIgnoringCase(str, start) : kNotFound; }
199 size_t findIgnoringCase(const String& str, unsigned start = 0) const 194 size_t findIgnoringCase(const String& str, unsigned start = 0) const
200 { return m_impl ? m_impl->findIgnoringCase(str.impl(), start) : kNotFoun d; } 195 { return m_impl ? m_impl->findIgnoringCase(str.impl(), start) : kNotFoun d; }
201 196
202 // ASCII case insensitive string matching. 197 // ASCII case insensitive string matching.
203 size_t findIgnoringASCIICase(const String& str, unsigned start = 0) const 198 size_t findIgnoringASCIICase(const String& str, unsigned start = 0) const
204 { return m_impl ? m_impl->findIgnoringASCIICase(str.impl(), start) : kNo tFound; } 199 { return m_impl ? m_impl->findIgnoringASCIICase(str.impl(), start) : kNo tFound; }
205 200
206 // Wrappers for find adding dynamic sensitivity check.
207 size_t find(const LChar* str, unsigned start, TextCaseSensitivity caseSensit ivity) const
208 { return DISPATCH_CASE_OP(caseSensitivity, find, (str, start)); }
209 size_t find(const String& str, unsigned start, TextCaseSensitivity caseSensi tivity) const
210 { return DISPATCH_CASE_OP(caseSensitivity, find, (str, start)); }
211
212 unsigned copyTo(UChar* buffer, unsigned pos, unsigned maxLength) const; 201 unsigned copyTo(UChar* buffer, unsigned pos, unsigned maxLength) const;
213 202
214 template<typename BufferType> 203 template<typename BufferType>
215 void appendTo(BufferType&, unsigned pos = 0, unsigned len = UINT_MAX) const; 204 void appendTo(BufferType&, unsigned pos = 0, unsigned len = UINT_MAX) const;
216 205
217 template<typename BufferType> 206 template<typename BufferType>
218 void prependTo(BufferType&, unsigned pos = 0, unsigned len = UINT_MAX) const ; 207 void prependTo(BufferType&, unsigned pos = 0, unsigned len = UINT_MAX) const ;
219 208
220 UChar32 characterStartingAt(unsigned) const; 209 UChar32 characterStartingAt(unsigned) const;
221 template<typename CharacterType> 210 template<typename CharacterType>
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 using WTF::append; 600 using WTF::append;
612 using WTF::charactersAreAllASCII; 601 using WTF::charactersAreAllASCII;
613 using WTF::equal; 602 using WTF::equal;
614 using WTF::find; 603 using WTF::find;
615 using WTF::isAllSpecialCharacters; 604 using WTF::isAllSpecialCharacters;
616 using WTF::isSpaceOrNewline; 605 using WTF::isSpaceOrNewline;
617 using WTF::reverseFind; 606 using WTF::reverseFind;
618 607
619 #include "wtf/text/AtomicString.h" 608 #include "wtf/text/AtomicString.h"
620 #endif // WTFString_h 609 #endif // WTFString_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698