Revert of Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies. (patchset #4 id:60001 of https://codereview.webrtc.org/1785713005/ )
Reason for revert:
I'm really sorry for having to revert this but it seems this hit an unexpected compile error downstream:
webrtc/media/sctp/sctpdataengine.cc: In function 'void cricket::VerboseLogPacket(const void*, size_t, int)':
webrtc/media/sctp/sctpdataengine.cc:172:37: error: invalid conversion from 'const void*' to 'void*' [-fpermissive]
data, length, direction)) != NULL) {
^
In file included from webrtc/media/sctp/sctpdataengine.cc:20:0:
third_party/usrsctp/usrsctplib/usrsctp.h:964:1: error: initializing argument 1 of 'char* usrsctp_dumppacket(void*, size_t, int)' [-fpermissive]
usrsctp_dumppacket(void *, size_t, int);
^
I'm sure you can fix this easily and just re-land this CL, while I'm going to look into how to add this warning at the public bots (on Monday).
Original issue's description:
> Use CopyOnWriteBuffer instead of Buffer to avoid unnecessary copies.
>
> This CL removes copy and assign support from Buffer and changes various
> parameters from Buffer to CopyOnWriteBuffer so they can be passed along
> and copied without actually copying the underlying data.
>
> With this changed some parameters to be "const" and fixed an issue when
> creating a CopyOnWriteBuffer with empty data.
>
> BUG=webrtc:5155
>
> Committed: https://crrev.com/944c39006f1c52aee20919676002dac7a42b1c05
> Cr-Commit-Position: refs/heads/master@{#12058}
TBR=kwiberg@webrtc.org,tkchin@webrtc.org,tommi@webrtc.org,pthatcher@webrtc.org,jbauch@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:5155
Review URL: https://codereview.webrtc.org/1817753003
Cr-Commit-Position: refs/heads/master@{#12060}
This commit is contained in:
@ -41,13 +41,6 @@ void EnsureBuffersDontShareData(const CopyOnWriteBuffer& buf1,
|
||||
EXPECT_NE(data1, data2);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestCreateEmptyData) {
|
||||
CopyOnWriteBuffer buf(static_cast<const uint8_t*>(nullptr), 0);
|
||||
EXPECT_EQ(buf.size(), 0u);
|
||||
EXPECT_EQ(buf.capacity(), 0u);
|
||||
EXPECT_EQ(buf.data(), nullptr);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestMoveConstruct) {
|
||||
CopyOnWriteBuffer buf1(kTestData, 3, 10);
|
||||
size_t buf1_size = buf1.size();
|
||||
@ -132,21 +125,6 @@ TEST(CopyOnWriteBufferTest, TestSetData) {
|
||||
EnsureBuffersDontShareData(buf1, buf3);
|
||||
const int8_t exp[] = {'f', 'o', 'o', 0x0};
|
||||
EXPECT_EQ(buf3, CopyOnWriteBuffer(exp));
|
||||
|
||||
buf2.SetData(static_cast<const uint8_t*>(nullptr), 0u);
|
||||
EnsureBuffersDontShareData(buf1, buf2);
|
||||
EXPECT_EQ(buf1.size(), 3u);
|
||||
EXPECT_EQ(buf1.capacity(), 10u);
|
||||
EXPECT_EQ(buf2.size(), 0u);
|
||||
EXPECT_EQ(buf2.capacity(), 0u);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestSetDataEmpty) {
|
||||
CopyOnWriteBuffer buf;
|
||||
buf.SetData(static_cast<const uint8_t*>(nullptr), 0u);
|
||||
EXPECT_EQ(buf.size(), 0u);
|
||||
EXPECT_EQ(buf.capacity(), 0u);
|
||||
EXPECT_EQ(buf.data(), nullptr);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestEnsureCapacity) {
|
||||
@ -218,43 +196,4 @@ TEST(CopyOnWriteBufferTest, TestConstDataAccessor) {
|
||||
EXPECT_EQ(data2, cdata1);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestBacketRead) {
|
||||
CopyOnWriteBuffer buf1(kTestData, 3, 10);
|
||||
CopyOnWriteBuffer buf2(buf1);
|
||||
|
||||
EnsureBuffersShareData(buf1, buf2);
|
||||
// Non-const reads clone the data if shared.
|
||||
for (size_t i = 0; i != 3u; ++i) {
|
||||
EXPECT_EQ(buf1[i], kTestData[i]);
|
||||
}
|
||||
EnsureBuffersDontShareData(buf1, buf2);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestBacketReadConst) {
|
||||
CopyOnWriteBuffer buf1(kTestData, 3, 10);
|
||||
CopyOnWriteBuffer buf2(buf1);
|
||||
|
||||
EnsureBuffersShareData(buf1, buf2);
|
||||
const CopyOnWriteBuffer& cbuf1 = buf1;
|
||||
for (size_t i = 0; i != 3u; ++i) {
|
||||
EXPECT_EQ(cbuf1[i], kTestData[i]);
|
||||
}
|
||||
EnsureBuffersShareData(buf1, buf2);
|
||||
}
|
||||
|
||||
TEST(CopyOnWriteBufferTest, TestBacketWrite) {
|
||||
CopyOnWriteBuffer buf1(kTestData, 3, 10);
|
||||
CopyOnWriteBuffer buf2(buf1);
|
||||
|
||||
EnsureBuffersShareData(buf1, buf2);
|
||||
for (size_t i = 0; i != 3u; ++i) {
|
||||
buf1[i] = kTestData[i] + 1;
|
||||
}
|
||||
EXPECT_EQ(buf1.size(), 3u);
|
||||
EXPECT_EQ(buf1.capacity(), 10u);
|
||||
EXPECT_EQ(buf2.size(), 3u);
|
||||
EXPECT_EQ(buf2.capacity(), 10u);
|
||||
EXPECT_EQ(0, memcmp(buf2.cdata(), kTestData, 3));
|
||||
}
|
||||
|
||||
} // namespace rtc
|
||||
|
||||
Reference in New Issue
Block a user