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

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

Issue 24043003: SerializedScriptValue's Writer calls realloc a lot (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 return; 66 return;
67 } 67 }
68 if (newLength > m_data->length()) { 68 if (newLength > m_data->length()) {
69 CharType* characters; 69 CharType* characters;
70 m_data = StringImpl::reallocate(m_data.release(), newLength, charact ers); 70 m_data = StringImpl::reallocate(m_data.release(), newLength, charact ers);
71 return; 71 return;
72 } 72 }
73 shrink(newLength); 73 shrink(newLength);
74 } 74 }
75 75
76 unsigned length() const { return m_data->length(); } 76 unsigned length() const { return m_data ? m_data->length() : 0; }
77 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get Characters<CharType>()) : 0; } 77 CharType* characters() { return length() ? const_cast<CharType*>(m_data->get Characters<CharType>()) : 0; }
78 78
79 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng th()); return characters()[i]; } 79 CharType& operator[](unsigned i) { ASSERT_WITH_SECURITY_IMPLICATION(i < leng th()); return characters()[i]; }
80 80
81 PassRefPtr<StringImpl> release() { return m_data.release(); } 81 PassRefPtr<StringImpl> release() { return m_data.release(); }
82 82
83 private: 83 private:
84 RefPtr<StringImpl> m_data; 84 RefPtr<StringImpl> m_data;
85 }; 85 };
86 86
87 } // namespace WTF 87 } // namespace WTF
88 88
89 using WTF::StringBuffer; 89 using WTF::StringBuffer;
90 90
91 #endif // StringBuffer_h 91 #endif // StringBuffer_h
OLDNEW
« no previous file with comments | « Source/bindings/v8/SerializedScriptValue.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698