Skip to content

Commit

Permalink
avoid assignment to self
Browse files Browse the repository at this point in the history
  • Loading branch information
w00384045 committed Jun 29, 2017
1 parent fdfb0e6 commit 11773a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions handy/net.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct Buffer {
Buffer& absorb(Buffer& buf);
void setSuggestSize(size_t sz) { exp_ = sz; }
Buffer(const Buffer& b) { copyFrom(b); }
Buffer& operator=(const Buffer& b) { delete[] buf_; buf_ = NULL; copyFrom(b); return *this; }
Buffer& operator=(const Buffer& b) { if(this == &b) return *this; delete[] buf_; buf_ = NULL; copyFrom(b); return *this; }
operator Slice () { return Slice(data(), size()); }
private:
char* buf_;
Expand All @@ -65,4 +65,4 @@ struct Buffer {
void copyFrom(const Buffer& b);
};

}
}

0 comments on commit 11773a3

Please sign in to comment.