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

Side by Side Diff: Source/wtf/text/StringBuffer.h

Issue 20002008: Don't use Vector<UChar> to build strings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix unit test Created 7 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « Source/core/platform/text/LocaleICU.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 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 if (newLength > m_data->length()) { 63 if (newLength > m_data->length()) {
64 RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / s izeof(UChar)); 64 RELEASE_ASSERT(newLength <= std::numeric_limits<unsigned>::max() / s izeof(UChar));
65 CharType* characters; 65 CharType* characters;
66 m_data = StringImpl::reallocate(m_data.release(), newLength, charact ers); 66 m_data = StringImpl::reallocate(m_data.release(), newLength, charact ers);
67 return; 67 return;
68 } 68 }
69 shrink(newLength); 69 shrink(newLength);
70 } 70 }
71 71
72 unsigned length() const { return m_data->length(); } 72 unsigned length() const { return m_data->length(); }
73 CharType* characters() { return const_cast<CharType*>(m_data->getCharacters< CharType>()); } 73 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get Characters<CharType>()) : 0; }
74 74
75 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng th()); return characters()[i]; } 75 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng th()); return characters()[i]; }
76 76
77 PassRefPtr<StringImpl> release() { return m_data.release(); } 77 PassRefPtr<StringImpl> release() { return m_data.release(); }
78 78
79 private: 79 private:
80 RefPtr<StringImpl> m_data; 80 RefPtr<StringImpl> m_data;
81 }; 81 };
82 82
83 } // namespace WTF 83 } // namespace WTF
84 84
85 using WTF::StringBuffer; 85 using WTF::StringBuffer;
86 86
87 #endif // StringBuffer_h 87 #endif // StringBuffer_h
OLDNEW
« no previous file with comments | « Source/core/platform/text/LocaleICU.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698