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

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

Issue 2610163004: Use StringView for String::split. (Closed)
Patch Set: Created 3 years, 11 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/WTFString.h ('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, 2010, 2012 Apple Inc. All rights 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Apple Inc. All rights
4 * reserved. 4 * reserved.
5 * Copyright (C) 2007-2009 Torch Mobile, Inc. 5 * Copyright (C) 2007-2009 Torch Mobile, Inc.
6 * 6 *
7 * This library is free software; you can redistribute it and/or 7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public 8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either 9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version. 10 * version 2 of the License, or (at your option) any later version.
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 String String::isolatedCopy() const { 489 String String::isolatedCopy() const {
490 if (!m_impl) 490 if (!m_impl)
491 return String(); 491 return String();
492 return m_impl->isolatedCopy(); 492 return m_impl->isolatedCopy();
493 } 493 }
494 494
495 bool String::isSafeToSendToAnotherThread() const { 495 bool String::isSafeToSendToAnotherThread() const {
496 return !m_impl || m_impl->isSafeToSendToAnotherThread(); 496 return !m_impl || m_impl->isSafeToSendToAnotherThread();
497 } 497 }
498 498
499 void String::split(const String& separator, 499 void String::split(const StringView& separator,
500 bool allowEmptyEntries, 500 bool allowEmptyEntries,
501 Vector<String>& result) const { 501 Vector<String>& result) const {
502 result.clear(); 502 result.clear();
503 503
504 unsigned startPos = 0; 504 unsigned startPos = 0;
505 size_t endPos; 505 size_t endPos;
506 while ((endPos = find(separator, startPos)) != kNotFound) { 506 while ((endPos = find(separator, startPos)) != kNotFound) {
507 if (allowEmptyEntries || startPos != endPos) 507 if (allowEmptyEntries || startPos != endPos)
508 result.append(substring(startPos, endPos - startPos)); 508 result.append(substring(startPos, endPos - startPos));
509 startPos = endPos + separator.length(); 509 startPos = endPos + separator.length();
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 } 846 }
847 buffer.append('\0'); 847 buffer.append('\0');
848 return buffer; 848 return buffer;
849 } 849 }
850 850
851 Vector<char> asciiDebug(String& string) { 851 Vector<char> asciiDebug(String& string) {
852 return asciiDebug(string.impl()); 852 return asciiDebug(string.impl());
853 } 853 }
854 854
855 #endif 855 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/WTFString.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698