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

Unified Diff: courgette/courgette_tool.cc

Issue 2143973004: Use memory mapped file in courgette_tool (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit cleanup Created 4 years, 5 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/courgette_tool.cc
diff --git a/courgette/courgette_tool.cc b/courgette/courgette_tool.cc
index d0fdb4e62bd5436f81a48bc6caa21b24359df31b..d667f91eb6b549169b0631477e345b0faa2d3d9e 100644
--- a/courgette/courgette_tool.cc
+++ b/courgette/courgette_tool.cc
@@ -57,20 +57,14 @@ void Problem(const char* format, ...) {
class BufferedFileReader {
public:
BufferedFileReader(const base::FilePath& file_name, const char* kind) {
- int64_t file_size = 0;
- if (!base::GetFileSize(file_name, &file_size))
+ if (!buffer_.Initialize(file_name))
Problem("Can't read %s file.", kind);
- buffer_.reserve(static_cast<size_t>(file_size));
- if (!base::ReadFileToString(file_name, &buffer_))
- Problem("Can't read %s file.", kind);
- }
- const uint8_t* data() {
- return reinterpret_cast<const uint8_t*>(buffer_.data());
}
- size_t length() { return buffer_.length(); }
+ const uint8_t* data() const { return buffer_.data(); }
+ size_t length() const { return buffer_.length(); }
private:
- std::string buffer_;
+ base::MemoryMappedFile buffer_;
};
void WriteSinkToFile(const courgette::SinkStream *sink,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698