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

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

Issue 2337683002: Move String::truncate to StringImpl. (Closed)
Patch Set: rebase Created 4 years, 3 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 /* 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 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r ights reserved.
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 int32_t realLength = Unicode::foldCase(data, length, characters16(), m_lengt h, &error); 890 int32_t realLength = Unicode::foldCase(data, length, characters16(), m_lengt h, &error);
891 if (!error && realLength == length) 891 if (!error && realLength == length)
892 return newImpl.release(); 892 return newImpl.release();
893 newImpl = createUninitialized(realLength, data); 893 newImpl = createUninitialized(realLength, data);
894 Unicode::foldCase(data, realLength, characters16(), m_length, &error); 894 Unicode::foldCase(data, realLength, characters16(), m_length, &error);
895 if (error) 895 if (error)
896 return this; 896 return this;
897 return newImpl.release(); 897 return newImpl.release();
898 } 898 }
899 899
900 PassRefPtr<StringImpl> StringImpl::truncate(unsigned length)
901 {
902 if (length >= m_length)
903 return this;
904 if (is8Bit())
905 return create(characters8(), length);
906 return create(characters16(), length);
907 }
908
900 template <class UCharPredicate> 909 template <class UCharPredicate>
901 inline PassRefPtr<StringImpl> StringImpl::stripMatchedCharacters(UCharPredicate predicate) 910 inline PassRefPtr<StringImpl> StringImpl::stripMatchedCharacters(UCharPredicate predicate)
902 { 911 {
903 if (!m_length) 912 if (!m_length)
904 return empty(); 913 return empty();
905 914
906 unsigned start = 0; 915 unsigned start = 0;
907 unsigned end = m_length - 1; 916 unsigned end = m_length - 1;
908 917
909 // skip white space from start 918 // skip white space from start
(...skipping 1141 matching lines...) Expand 10 before | Expand all | Expand 10 after
2051 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2060 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2052 // TODO(rob.buis) implement upper-casing rules for lt 2061 // TODO(rob.buis) implement upper-casing rules for lt
2053 // like in StringImpl::upper(locale). 2062 // like in StringImpl::upper(locale).
2054 } 2063 }
2055 } 2064 }
2056 2065
2057 return toUpper(c); 2066 return toUpper(c);
2058 } 2067 }
2059 2068
2060 } // namespace WTF 2069 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/WTFString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698