diff options
author | Remko Tronçon <git@el-tramo.be> | 2011-09-30 18:46:42 (GMT) |
---|---|---|
committer | Remko Tronçon <git@el-tramo.be> | 2011-09-30 18:46:42 (GMT) |
commit | 1b255f6ba90847240b92126deb5ea0174ad269b0 (patch) | |
tree | 9d56e647ebc35c0f0941d19a302b888c1185ce1c /Swiften/FileTransfer/IBBSendSession.cpp | |
parent | af976a75b5e1b504a340602659ef930109cd2c48 (diff) | |
download | swift-contrib-1b255f6ba90847240b92126deb5ea0174ad269b0.zip swift-contrib-1b255f6ba90847240b92126deb5ea0174ad269b0.tar.bz2 |
Avoid a copy when reading from a byte array.
Diffstat (limited to 'Swiften/FileTransfer/IBBSendSession.cpp')
-rw-r--r-- | Swiften/FileTransfer/IBBSendSession.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Swiften/FileTransfer/IBBSendSession.cpp b/Swiften/FileTransfer/IBBSendSession.cpp index 3a1390c..c24cc0a 100644 --- a/Swiften/FileTransfer/IBBSendSession.cpp +++ b/Swiften/FileTransfer/IBBSendSession.cpp @@ -8,6 +8,7 @@ #include <boost/bind.hpp> +#include <Swiften/Base/ByteArray.h> #include <Swiften/Queries/IQRouter.h> #include <Swiften/FileTransfer/IBBRequest.h> #include <Swiften/FileTransfer/BytestreamException.h> @@ -52,14 +53,14 @@ void IBBSendSession::handleIBBResponse(IBB::ref, ErrorPayload::ref error) { void IBBSendSession::sendMoreData() { try { - std::vector<unsigned char> data = bytestream->read(blockSize); - if (!data.empty()) { + boost::shared_ptr<ByteArray> data = bytestream->read(blockSize); + if (!data->empty()) { waitingForData = false; - IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBData(id, sequenceNumber, data), router); + IBBRequest::ref request = IBBRequest::create(from, to, IBB::createIBBData(id, sequenceNumber, *data), router); sequenceNumber++; request->onResponse.connect(boost::bind(&IBBSendSession::handleIBBResponse, this, _1, _2)); request->send(); - onBytesSent(data.size()); + onBytesSent(data->size()); } else { waitingForData = true; |