Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/FileSystemJsObject.cpp

Issue 29481704: Noissue - Use buffer for FileSystem IO (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Nit addressed Created July 7, 2017, 12:50 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/DefaultFileSystem.cpp ('k') | src/Utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/FileSystemJsObject.cpp
===================================================================
--- a/src/FileSystemJsObject.cpp
+++ b/src/FileSystemJsObject.cpp
@@ -56,18 +56,18 @@
}
void Run()
{
std::string content;
std::string error;
try
{
- std::shared_ptr<std::istream> stream = fileSystem->Read(path);
- content = Utils::Slurp(*stream);
+ auto buffer = fileSystem->Read(path);
+ content = std::string(buffer.cbegin(), buffer.cend());
}
catch (std::exception& e)
{
error = e.what();
}
catch (...)
{
error = "Unknown error while reading from " + path;
@@ -95,19 +95,18 @@
{
}
void Run()
{
std::string error;
try
{
- std::stringstream stream;
- stream << content;
- fileSystem->Write(path, stream);
+ FileSystem::IOBuffer buffer(content.cbegin(), content.cend());
+ fileSystem->Write(path, buffer);
}
catch (std::exception& e)
{
error = e.what();
}
catch (...)
{
error = "Unknown error while writing to " + path;
« no previous file with comments | « src/DefaultFileSystem.cpp ('k') | src/Utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld