mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-02-01 05:01:59 +01:00
[BinaryStream] Defaultify copy and move constructors.
The various BinaryStream classes had explicit copy constructors which resulted in deleted move constructors. This was causing the internal std::shared_ptr to get copied rather than moved very frequently, since these classes are often used as return values. Patch by Alex Telishev Differential Revision: https://reviews.llvm.org/D36942 llvm-svn: 311368
This commit is contained in:
parent
15b60a8a80
commit
755cbbac1f
@ -31,12 +31,11 @@ protected:
|
|||||||
BinaryStreamRefBase(StreamType &BorrowedImpl, uint32_t Offset,
|
BinaryStreamRefBase(StreamType &BorrowedImpl, uint32_t Offset,
|
||||||
uint32_t Length)
|
uint32_t Length)
|
||||||
: BorrowedImpl(&BorrowedImpl), ViewOffset(Offset), Length(Length) {}
|
: BorrowedImpl(&BorrowedImpl), ViewOffset(Offset), Length(Length) {}
|
||||||
BinaryStreamRefBase(const BinaryStreamRefBase &Other) {
|
BinaryStreamRefBase(const BinaryStreamRefBase &Other) = default;
|
||||||
SharedImpl = Other.SharedImpl;
|
BinaryStreamRefBase &operator=(const BinaryStreamRefBase &Other) = default;
|
||||||
BorrowedImpl = Other.BorrowedImpl;
|
|
||||||
ViewOffset = Other.ViewOffset;
|
BinaryStreamRefBase &operator=(BinaryStreamRefBase &&Other) = default;
|
||||||
Length = Other.Length;
|
BinaryStreamRefBase(BinaryStreamRefBase &&Other) = default;
|
||||||
}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
llvm::support::endianness getEndian() const {
|
llvm::support::endianness getEndian() const {
|
||||||
@ -142,7 +141,10 @@ public:
|
|||||||
llvm::support::endianness Endian);
|
llvm::support::endianness Endian);
|
||||||
explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian);
|
explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian);
|
||||||
|
|
||||||
BinaryStreamRef(const BinaryStreamRef &Other);
|
BinaryStreamRef(const BinaryStreamRef &Other) = default;
|
||||||
|
BinaryStreamRef &operator=(const BinaryStreamRef &Other) = default;
|
||||||
|
BinaryStreamRef(BinaryStreamRef &&Other) = default;
|
||||||
|
BinaryStreamRef &operator=(BinaryStreamRef &&Other) = default;
|
||||||
|
|
||||||
// Use BinaryStreamRef.slice() instead.
|
// Use BinaryStreamRef.slice() instead.
|
||||||
BinaryStreamRef(BinaryStreamRef &S, uint32_t Offset,
|
BinaryStreamRef(BinaryStreamRef &S, uint32_t Offset,
|
||||||
@ -203,7 +205,12 @@ public:
|
|||||||
uint32_t Length);
|
uint32_t Length);
|
||||||
explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
|
explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
|
||||||
llvm::support::endianness Endian);
|
llvm::support::endianness Endian);
|
||||||
WritableBinaryStreamRef(const WritableBinaryStreamRef &Other);
|
WritableBinaryStreamRef(const WritableBinaryStreamRef &Other) = default;
|
||||||
|
WritableBinaryStreamRef &
|
||||||
|
operator=(const WritableBinaryStreamRef &Other) = default;
|
||||||
|
|
||||||
|
WritableBinaryStreamRef(WritableBinaryStreamRef &&Other) = default;
|
||||||
|
WritableBinaryStreamRef &operator=(WritableBinaryStreamRef &&Other) = default;
|
||||||
|
|
||||||
// Use WritableBinaryStreamRef.slice() instead.
|
// Use WritableBinaryStreamRef.slice() instead.
|
||||||
WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint32_t Offset,
|
WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint32_t Offset,
|
||||||
|
@ -77,9 +77,6 @@ BinaryStreamRef::BinaryStreamRef(StringRef Data, endianness Endian)
|
|||||||
: BinaryStreamRef(makeArrayRef(Data.bytes_begin(), Data.bytes_end()),
|
: BinaryStreamRef(makeArrayRef(Data.bytes_begin(), Data.bytes_end()),
|
||||||
Endian) {}
|
Endian) {}
|
||||||
|
|
||||||
BinaryStreamRef::BinaryStreamRef(const BinaryStreamRef &Other)
|
|
||||||
: BinaryStreamRefBase(Other) {}
|
|
||||||
|
|
||||||
Error BinaryStreamRef::readBytes(uint32_t Offset, uint32_t Size,
|
Error BinaryStreamRef::readBytes(uint32_t Offset, uint32_t Size,
|
||||||
ArrayRef<uint8_t> &Buffer) const {
|
ArrayRef<uint8_t> &Buffer) const {
|
||||||
if (auto EC = checkOffset(Offset, Size))
|
if (auto EC = checkOffset(Offset, Size))
|
||||||
@ -117,9 +114,6 @@ WritableBinaryStreamRef::WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
|
|||||||
: BinaryStreamRefBase(std::make_shared<MutableArrayRefImpl>(Data, Endian),
|
: BinaryStreamRefBase(std::make_shared<MutableArrayRefImpl>(Data, Endian),
|
||||||
0, Data.size()) {}
|
0, Data.size()) {}
|
||||||
|
|
||||||
WritableBinaryStreamRef::WritableBinaryStreamRef(
|
|
||||||
const WritableBinaryStreamRef &Other)
|
|
||||||
: BinaryStreamRefBase(Other) {}
|
|
||||||
|
|
||||||
Error WritableBinaryStreamRef::writeBytes(uint32_t Offset,
|
Error WritableBinaryStreamRef::writeBytes(uint32_t Offset,
|
||||||
ArrayRef<uint8_t> Data) const {
|
ArrayRef<uint8_t> Data) const {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user