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

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

Issue 1391153004: Make StringImpl's content immutable (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: bug fix: StringBuffer::release returns m_data directly Created 5 years, 2 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.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 * 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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 static PassRefPtr<StringImpl> caseConvert(const UChar* source16, size_t length, icuCaseConverter converter, const char* locale, StringImpl* originalString) 675 static PassRefPtr<StringImpl> caseConvert(const UChar* source16, size_t length, icuCaseConverter converter, const char* locale, StringImpl* originalString)
676 { 676 {
677 UChar* data16; 677 UChar* data16;
678 size_t targetLength = length; 678 size_t targetLength = length;
679 RefPtr<StringImpl> output = StringImpl::createUninitialized(length, data16); 679 RefPtr<StringImpl> output = StringImpl::createUninitialized(length, data16);
680 do { 680 do {
681 UErrorCode status = U_ZERO_ERROR; 681 UErrorCode status = U_ZERO_ERROR;
682 targetLength = converter(data16, targetLength, source16, length, locale, &status); 682 targetLength = converter(data16, targetLength, source16, length, locale, &status);
683 if (U_SUCCESS(status)) { 683 if (U_SUCCESS(status)) {
684 if (length > 0) 684 if (length > 0)
685 output->truncateAssumingIsolated(targetLength); 685 return output->substring(0, targetLength);
686 return output.release(); 686 return output.release();
687 } 687 }
688 if (status != U_BUFFER_OVERFLOW_ERROR) 688 if (status != U_BUFFER_OVERFLOW_ERROR)
689 return originalString; 689 return originalString;
690 // Expand the buffer. 690 // Expand the buffer.
691 output = StringImpl::createUninitialized(targetLength, data16); 691 output = StringImpl::createUninitialized(targetLength, data16);
692 } while (true); 692 } while (true);
693 } 693 }
694 694
695 PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier) 695 PassRefPtr<StringImpl> StringImpl::lower(const AtomicString& localeIdentifier)
(...skipping 1413 matching lines...) Expand 10 before | Expand all | Expand 10 after
2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2109 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2110 // TODO(rob.buis) implement upper-casing rules for lt 2110 // TODO(rob.buis) implement upper-casing rules for lt
2111 // like in StringImpl::upper(locale). 2111 // like in StringImpl::upper(locale).
2112 } 2112 }
2113 } 2113 }
2114 2114
2115 return toUpper(c); 2115 return toUpper(c);
2116 } 2116 }
2117 2117
2118 } // namespace WTF 2118 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698