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

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

Issue 2241573004: Use StringView for String::replace. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: woops. 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 | « no previous file | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | 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 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2013 Apple Inc. All rights reserved.
4 * Copyright (C) 2009 Google Inc. All rights reserved. 4 * Copyright (C) 2009 Google Inc. All rights reserved.
5 * 5 *
6 * This library is free software; you can redistribute it and/or 6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public 7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either 8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version. 9 * version 2 of the License, or (at your option) any later version.
10 * 10 *
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
386 bool startsWith(UChar) const; 386 bool startsWith(UChar) const;
387 bool startsWith(const StringView&) const; 387 bool startsWith(const StringView&) const;
388 bool startsWithIgnoringCase(const StringView&) const; 388 bool startsWithIgnoringCase(const StringView&) const;
389 bool startsWithIgnoringASCIICase(const StringView&) const; 389 bool startsWithIgnoringASCIICase(const StringView&) const;
390 390
391 bool endsWith(UChar) const; 391 bool endsWith(UChar) const;
392 bool endsWith(const StringView&) const; 392 bool endsWith(const StringView&) const;
393 bool endsWithIgnoringCase(const StringView&) const; 393 bool endsWithIgnoringCase(const StringView&) const;
394 bool endsWithIgnoringASCIICase(const StringView&) const; 394 bool endsWithIgnoringASCIICase(const StringView&) const;
395 395
396 PassRefPtr<StringImpl> replace(UChar, UChar); 396 // Replace parts of the string.
397 PassRefPtr<StringImpl> replace(UChar, StringImpl*); 397 PassRefPtr<StringImpl> replace(UChar pattern, UChar replacement);
398 ALWAYS_INLINE PassRefPtr<StringImpl> replace(UChar pattern, const char* repl acement, unsigned replacementLength) { return replace(pattern, reinterpret_cast< const LChar*>(replacement), replacementLength); } 398 PassRefPtr<StringImpl> replace(UChar pattern, const StringView& replacement) ;
399 PassRefPtr<StringImpl> replace(UChar, const LChar*, unsigned replacementLeng th); 399 PassRefPtr<StringImpl> replace(const StringView& pattern, const StringView& replacement);
400 PassRefPtr<StringImpl> replace(UChar, const UChar*, unsigned replacementLeng th); 400 PassRefPtr<StringImpl> replace(unsigned index, unsigned lengthToReplace, con st StringView& replacement);
401 PassRefPtr<StringImpl> replace(StringImpl*, StringImpl*); 401
402 PassRefPtr<StringImpl> replace(unsigned index, unsigned len, StringImpl*);
403 PassRefPtr<StringImpl> upconvertedString(); 402 PassRefPtr<StringImpl> upconvertedString();
404 403
405 #if OS(MACOSX) 404 #if OS(MACOSX)
406 RetainPtr<CFStringRef> createCFString(); 405 RetainPtr<CFStringRef> createCFString();
407 #endif 406 #endif
408 #ifdef __OBJC__ 407 #ifdef __OBJC__
409 operator NSString*(); 408 operator NSString*();
410 #endif 409 #endif
411 410
412 #ifdef STRING_STATS 411 #ifdef STRING_STATS
413 ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; } 412 ALWAYS_INLINE static StringStats& stringStats() { return m_stringStats; }
414 #endif 413 #endif
415 static const UChar latin1CaseFoldTable[256]; 414 static const UChar latin1CaseFoldTable[256];
416 415
417 private: 416 private:
418 template<typename CharType> static size_t allocationSize(unsigned length) 417 template<typename CharType> static size_t allocationSize(unsigned length)
419 { 418 {
420 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof (StringImpl)) / sizeof(CharType))); 419 RELEASE_ASSERT(length <= ((std::numeric_limits<unsigned>::max() - sizeof (StringImpl)) / sizeof(CharType)));
421 return sizeof(StringImpl) + length * sizeof(CharType); 420 return sizeof(StringImpl) + length * sizeof(CharType);
422 } 421 }
423 422
423 PassRefPtr<StringImpl> replace(UChar pattern, const LChar* replacement, unsi gned replacementLength);
424 PassRefPtr<StringImpl> replace(UChar pattern, const UChar* replacement, unsi gned replacementLength);
425
424 template <class UCharPredicate> PassRefPtr<StringImpl> stripMatchedCharacter s(UCharPredicate); 426 template <class UCharPredicate> PassRefPtr<StringImpl> stripMatchedCharacter s(UCharPredicate);
425 template <typename CharType, class UCharPredicate> PassRefPtr<StringImpl> si mplifyMatchedCharactersToSpace(UCharPredicate, StripBehavior); 427 template <typename CharType, class UCharPredicate> PassRefPtr<StringImpl> si mplifyMatchedCharactersToSpace(UCharPredicate, StripBehavior);
426 NEVER_INLINE unsigned hashSlowCase() const; 428 NEVER_INLINE unsigned hashSlowCase() const;
427 429
428 #ifdef STRING_STATS 430 #ifdef STRING_STATS
429 static StringStats m_stringStats; 431 static StringStats m_stringStats;
430 #endif 432 #endif
431 433
432 static unsigned m_highestStaticStringLength; 434 static unsigned m_highestStaticStringLength;
433 435
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
715 using WTF::TextCaseASCIIInsensitive; 717 using WTF::TextCaseASCIIInsensitive;
716 using WTF::TextCaseInsensitive; 718 using WTF::TextCaseInsensitive;
717 using WTF::TextCaseSensitive; 719 using WTF::TextCaseSensitive;
718 using WTF::TextCaseSensitivity; 720 using WTF::TextCaseSensitivity;
719 using WTF::equal; 721 using WTF::equal;
720 using WTF::equalNonNull; 722 using WTF::equalNonNull;
721 using WTF::lengthOfNullTerminatedString; 723 using WTF::lengthOfNullTerminatedString;
722 using WTF::reverseFind; 724 using WTF::reverseFind;
723 725
724 #endif 726 #endif
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/wtf/text/StringImpl.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698