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: Created July 6, 2017, 9:19 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
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;
« src/DefaultFileSystem.cpp ('K') | « src/DefaultFileSystem.cpp ('k') | test/BaseJsTest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld