summaryrefslogtreecommitdiff
path: root/zen/serialize.h
diff options
context:
space:
mode:
authorDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:01:21 +0200
committerDaniel Wilhelm <shieldwed@outlook.com>2018-05-09 00:01:21 +0200
commitb962d4fd3f8e802b99bd9c074851fd0f05a12adb (patch)
tree13a12ded9c3a9713a8c368975a95f5efe6ec997c /zen/serialize.h
parent9.2 (diff)
downloadFreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.tar.gz
FreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.tar.bz2
FreeFileSync-b962d4fd3f8e802b99bd9c074851fd0f05a12adb.zip
9.3
Diffstat (limited to 'zen/serialize.h')
-rwxr-xr-xzen/serialize.h23
1 files changed, 11 insertions, 12 deletions
diff --git a/zen/serialize.h b/zen/serialize.h
index 81d2d1ef..8f7e813c 100755
--- a/zen/serialize.h
+++ b/zen/serialize.h
@@ -36,20 +36,20 @@ public:
using iterator = std::vector<char>::iterator;
using const_iterator = std::vector<char>::const_iterator;
- iterator begin() { return buffer->begin(); }
- iterator end () { return buffer->end (); }
+ iterator begin() { return buffer_->begin(); }
+ iterator end () { return buffer_->end (); }
- const_iterator begin() const { return buffer->begin(); }
- const_iterator end () const { return buffer->end (); }
+ const_iterator begin() const { return buffer_->begin(); }
+ const_iterator end () const { return buffer_->end (); }
- void resize(size_t len) { buffer->resize(len); }
- size_t size() const { return buffer->size(); }
- bool empty() const { return buffer->empty(); }
+ void resize(size_t len) { buffer_->resize(len); }
+ size_t size() const { return buffer_->size(); }
+ bool empty() const { return buffer_->empty(); }
- inline friend bool operator==(const ByteArray& lhs, const ByteArray& rhs) { return *lhs.buffer == *rhs.buffer; }
+ inline friend bool operator==(const ByteArray& lhs, const ByteArray& rhs) { return *lhs.buffer_ == *rhs.buffer_; }
private:
- std::shared_ptr<std::vector<char>> buffer { std::make_shared<std::vector<char>>() }; //always bound!
+ std::shared_ptr<std::vector<char>> buffer_ { std::make_shared<std::vector<char>>() }; //always bound!
//perf: shared_ptr indirection irrelevant: less than 1% slower!
};
@@ -148,9 +148,8 @@ struct MemoryStreamOut
void write(const void* buffer, size_t bytesToWrite)
{
static_assert(sizeof(typename BinContainer::value_type) == 1, ""); //expect: bytes
- const size_t oldSize = buffer_.size();
- buffer_.resize(oldSize + bytesToWrite);
- std::copy(static_cast<const char*>(buffer), static_cast<const char*>(buffer) + bytesToWrite, buffer_.begin() + oldSize);
+ buffer_.resize(buffer_.size() + bytesToWrite);
+ std::copy(static_cast<const char*>(buffer), static_cast<const char*>(buffer) + bytesToWrite, buffer_.end() - bytesToWrite);
}
const BinContainer& ref() const { return buffer_; }
bgstack15