Skip to content

Commit 903fe95

Browse files
Morel BérengerAntoine Fontaine
authored andcommitted
minor perf patch for IPC Reader
1 parent 0e9875f commit 903fe95

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
@@ -132,10 +132,16 @@ namespace Util {
132132
public:
133133
Reader()
134134
: pos(0), handles_pos(0) {}
135+
Reader(Reader const& other) = delete;
136+
Reader& operator=(Reader const& other) = delete;
135137
Reader(Reader&& other) NOEXCEPT
136138
: data(std::move(other.data)), handles(std::move(other.handles)), pos(other.pos), handles_pos(other.handles_pos) {}
137139
Reader& operator=(Reader&& other) NOEXCEPT
138140
{
141+
if (this == &other)
142+
{
143+
return *this;
144+
}
139145
std::swap(data, other.data);
140146
std::swap(handles, other.handles);
141147
std::swap(pos, other.pos);
@@ -145,8 +151,8 @@ namespace Util {
145151
~Reader()
146152
{
147153
// Close any handles that weren't read
148-
for (size_t i = handles_pos; i < handles.size(); i++)
149-
handles[i].Close();
154+
for (auto it = handles.begin() + handles_pos; it != handles.end(); ++it)
155+
it->Close();
150156
}
151157

152158
void ReadData(void* p, size_t len)

0 commit comments

Comments
 (0)