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

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

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
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 private: 63 private:
64 RefPtr<StringImpl> m_data; 64 RefPtr<StringImpl> m_data;
65 }; 65 };
66 66
67 template <typename CharType> 67 template <typename CharType>
68 void StringBuffer<CharType>::shrink(unsigned newLength) 68 void StringBuffer<CharType>::shrink(unsigned newLength)
69 { 69 {
70 ASSERT(m_data); 70 ASSERT(m_data);
71 if (m_data->length() == newLength) 71 if (m_data->length() == newLength)
72 return; 72 return;
73 m_data->truncateAssumingIsolated(newLength); 73 m_data = m_data->substring(0, newLength);
74 } 74 }
75 75
76 } // namespace WTF 76 } // namespace WTF
77 77
78 using WTF::StringBuffer; 78 using WTF::StringBuffer;
79 79
80 #endif // StringBuffer_h 80 #endif // StringBuffer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698