Skip to content

Commit e5d390d

Browse files
Morel BérengerVReaperV
authored andcommitted
minor perf patch for IPC Reader
1 parent 33c2e43 commit e5d390d

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/common/Serialize.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,16 @@ namespace Util {
130130
public:
131131
Reader()
132132
: pos(0), handles_pos(0) {}
133+
Reader(Reader const& other) = delete;
134+
Reader& operator=(Reader const& other) = delete;
133135
Reader(Reader&& other) NOEXCEPT
134136
: data(std::move(other.data)), handles(std::move(other.handles)), pos(other.pos), handles_pos(other.handles_pos) {}
135137
Reader& operator=(Reader&& other) NOEXCEPT
136138
{
139+
if (this == &other)
140+
{
141+
return *this;
142+
}
137143
std::swap(data, other.data);
138144
std::swap(handles, other.handles);
139145
std::swap(pos, other.pos);
@@ -143,8 +149,8 @@ namespace Util {
143149
~Reader()
144150
{
145151
// Close any handles that weren't read
146-
for (size_t i = handles_pos; i < handles.size(); i++)
147-
handles[i].Close();
152+
for (auto it = handles.begin() + handles_pos; it != handles.end(); ++it)
153+
it->Close();
148154
}
149155

150156
void ReadData(void* p, size_t len)

0 commit comments

Comments
 (0)