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

Unified Diff: pdf/document_loader.cc

Issue 1587083004: PDF: Use a vector instead of a list in DocumentLoader. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
« no previous file with comments | « pdf/document_loader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pdf/document_loader.cc
diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc
index b5f80e41461dc2e645d0731dc0465051ec33bfa2..f450503539065e32ec2d41cbf0f35b17376645e8 100644
--- a/pdf/document_loader.cc
+++ b/pdf/document_loader.cc
@@ -449,9 +449,9 @@ void DocumentLoader::DidRead(int32_t result) {
// memory fragmentation issues on the large files and OOM exceptions.
// To fix this, we collect all chunks of the file to the list and
// concatenate them together after request is complete.
- chunk_buffer_.push_back(std::vector<unsigned char>());
- chunk_buffer_.back().resize(length);
- memcpy(&(chunk_buffer_.back()[0]), start, length);
+ std::vector<unsigned char> buf(length);
+ memcpy(buf.data(), start, length);
+ chunk_buffer_.push_back(std::move(buf));
}
current_pos_ += length;
current_chunk_read_ += length;
@@ -511,7 +511,7 @@ void DocumentLoader::ReadComplete() {
chunk_stream_.Preallocate(current_pos_);
uint32_t pos = 0;
for (auto& chunk : chunk_buffer_) {
- chunk_stream_.WriteData(pos, &(chunk[0]), chunk.size());
+ chunk_stream_.WriteData(pos, chunk.data(), chunk.size());
pos += chunk.size();
}
chunk_buffer_.clear();
« no previous file with comments | « pdf/document_loader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698