summaryrefslogtreecommitdiff
path: root/test/fixtures
diff options
context:
space:
mode:
authorKonstantin Käfer <mail@kkaefer.com>2015-10-16 16:14:55 +0200
committerKonstantin Käfer <mail@kkaefer.com>2015-10-26 15:54:27 +0100
commit5173bf1bb8d21054b0dd6251d23eb37323d6c525 (patch)
treed13536c22b8279e9fd7e8f4892596c42973170f3 /test/fixtures
parent4e3503ea6cf30c55a2cc86f78c4a607bd14f1c41 (diff)
downloadqtlocation-mapboxgl-5173bf1bb8d21054b0dd6251d23eb37323d6c525.tar.gz
[core] Make response data shared to avoid excessive copying
Diffstat (limited to 'test/fixtures')
-rw-r--r--test/fixtures/mock_file_source.cpp7
1 files changed, 4 insertions, 3 deletions
diff --git a/test/fixtures/mock_file_source.cpp b/test/fixtures/mock_file_source.cpp
index b420ba7298..407f54408f 100644
--- a/test/fixtures/mock_file_source.cpp
+++ b/test/fixtures/mock_file_source.cpp
@@ -55,7 +55,7 @@ void MockFileSource::Impl::replyWithSuccess(Request* req) const {
res->status = Response::Status::Successful;
try {
- res->data = util::read_file(req->resource.url);
+ res->data = std::make_shared<const std::string>(std::move(util::read_file(req->resource.url)));
} catch (const std::exception& err) {
res->status = Response::Status::Error;
res->message = err.what();
@@ -95,8 +95,9 @@ void MockFileSource::Impl::replyWithCorruptedData(Request* req) const {
std::shared_ptr<Response> res = std::make_shared<Response>();
res->status = Response::Status::Successful;
- res->data = util::read_file(req->resource.url);
- res->data.insert(0, "CORRUPTED");
+ auto data = std::make_shared<std::string>(std::move(util::read_file(req->resource.url)));
+ data->insert(0, "CORRUPTED");
+ res->data = std::move(data);
req->notify(res);
}