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

Unified Diff: courgette/streams.cc

Issue 6546008: Improved memory usage while applying patch.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 10 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 side-by-side diff with in-line comments
Download patch
« courgette/courgette_tool.cc ('K') | « courgette/streams.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/streams.cc
===================================================================
--- courgette/streams.cc (revision 75361)
+++ courgette/streams.cc (working copy)
@@ -211,10 +211,14 @@
void SinkStream::Append(SinkStream* other) {
Write(other->buffer_.c_str(), other->buffer_.size());
- other->buffer_.clear();
- other->buffer_.reserve(0); // Non-binding request to reduce storage.
+ other->Retire();
}
+void SinkStream::Retire() {
+ buffer_.clear();
+ buffer_.reserve(0); // Non-binding request to reduce storage.
+}
+
////////////////////////////////////////////////////////////////////////////////
SourceStreamSet::SourceStreamSet()
@@ -335,6 +339,14 @@
bool SinkStreamSet::CopyTo(SinkStream *combined_stream) {
SinkStream header;
CopyHeaderTo(&header);
+
+ // Reserve the correct amount of storage.
+ size_t length = header.Length();
+ for (size_t i = 0; i < count_; ++i) {
+ length += stream(i)->Length();
+ }
+ combined_stream->Reserve(length);
+
combined_stream->Append(&header);
for (size_t i = 0; i < count_; ++i) {
combined_stream->Append(stream(i));
« courgette/courgette_tool.cc ('K') | « courgette/streams.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698