diff options
author | thestig <thestig@chromium.org> | 2016-01-15 11:18:10 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-15 19:19:02 +0000 |
commit | d9b9c9ec0097c4b544872ffa0ee03055aae7d859 (patch) | |
tree | ee7bc3e62750d6272dbc64b5c25f2ef0051b511a /pdf | |
parent | 73506ba56399118372485a31dbf1454c3ff2d3f0 (diff) | |
download | chromium_src-d9b9c9ec0097c4b544872ffa0ee03055aae7d859.zip chromium_src-d9b9c9ec0097c4b544872ffa0ee03055aae7d859.tar.gz chromium_src-d9b9c9ec0097c4b544872ffa0ee03055aae7d859.tar.bz2 |
PDF: Use a vector instead of a list in DocumentLoader.
Review URL: https://codereview.chromium.org/1587083004
Cr-Commit-Position: refs/heads/master@{#369803}
Diffstat (limited to 'pdf')
-rw-r--r-- | pdf/document_loader.cc | 8 | ||||
-rw-r--r-- | pdf/document_loader.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/pdf/document_loader.cc b/pdf/document_loader.cc index b5f80e41..f450503 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(); diff --git a/pdf/document_loader.h b/pdf/document_loader.h index c9d355b..af39390 100644 --- a/pdf/document_loader.h +++ b/pdf/document_loader.h @@ -128,7 +128,7 @@ class DocumentLoader { bool is_multipart_; std::string multipart_boundary_; uint32_t requests_count_; - std::list<std::vector<unsigned char> > chunk_buffer_; + std::vector<std::vector<unsigned char> > chunk_buffer_; }; } // namespace chrome_pdf |