@@ -31,10 +31,9 @@ static void dtorTy(Block *, std::byte *Ptr, const Descriptor *) {
31
31
}
32
32
33
33
template <typename T>
34
- static void moveTy (Block *, const std::byte *Src, std::byte *Dst,
34
+ static void moveTy (Block *, std::byte *Src, std::byte *Dst,
35
35
const Descriptor *) {
36
- // FIXME: Get rid of the const_cast.
37
- auto *SrcPtr = reinterpret_cast <T *>(const_cast <std::byte *>(Src));
36
+ auto *SrcPtr = reinterpret_cast <T *>(Src);
38
37
auto *DstPtr = reinterpret_cast <T *>(Dst);
39
38
new (DstPtr) T (std::move (*SrcPtr));
40
39
}
@@ -63,11 +62,9 @@ static void dtorArrayTy(Block *, std::byte *Ptr, const Descriptor *D) {
63
62
}
64
63
65
64
template <typename T>
66
- static void moveArrayTy (Block *, const std::byte *Src, std::byte *Dst,
65
+ static void moveArrayTy (Block *, std::byte *Src, std::byte *Dst,
67
66
const Descriptor *D) {
68
- // FIXME: Get rid of the const_cast.
69
- InitMapPtr &SrcIMP =
70
- *reinterpret_cast <InitMapPtr *>(const_cast <std::byte *>(Src));
67
+ InitMapPtr &SrcIMP = *reinterpret_cast <InitMapPtr *>(Src);
71
68
if (SrcIMP) {
72
69
// We only ever invoke the moveFunc when moving block contents to a
73
70
// DeadBlock. DeadBlocks don't need InitMaps, so we destroy them here.
@@ -76,7 +73,7 @@ static void moveArrayTy(Block *, const std::byte *Src, std::byte *Dst,
76
73
Src += sizeof (InitMapPtr);
77
74
Dst += sizeof (InitMapPtr);
78
75
for (unsigned I = 0 , NE = D->getNumElems (); I < NE; ++I) {
79
- auto *SrcPtr = &reinterpret_cast <T *>(const_cast <std::byte *>( Src) )[I];
76
+ auto *SrcPtr = &reinterpret_cast <T *>(Src)[I];
80
77
auto *DstPtr = &reinterpret_cast <T *>(Dst)[I];
81
78
new (DstPtr) T (std::move (*SrcPtr));
82
79
}
@@ -126,19 +123,19 @@ static void dtorArrayDesc(Block *B, std::byte *Ptr, const Descriptor *D) {
126
123
}
127
124
}
128
125
129
- static void moveArrayDesc (Block *B, const std::byte *Src, std::byte *Dst,
126
+ static void moveArrayDesc (Block *B, std::byte *Src, std::byte *Dst,
130
127
const Descriptor *D) {
131
128
const unsigned NumElems = D->getNumElems ();
132
129
const unsigned ElemSize =
133
130
D->ElemDesc ->getAllocSize () + sizeof (InlineDescriptor);
134
131
135
132
unsigned ElemOffset = 0 ;
136
133
for (unsigned I = 0 ; I < NumElems; ++I, ElemOffset += ElemSize) {
137
- const auto *SrcPtr = Src + ElemOffset;
134
+ auto *SrcPtr = Src + ElemOffset;
138
135
auto *DstPtr = Dst + ElemOffset;
139
136
140
- const auto *SrcDesc = reinterpret_cast <const InlineDescriptor *>(SrcPtr);
141
- const auto *SrcElemLoc = reinterpret_cast <const std::byte *>(SrcDesc + 1 );
137
+ auto *SrcDesc = reinterpret_cast <InlineDescriptor *>(SrcPtr);
138
+ auto *SrcElemLoc = reinterpret_cast <std::byte *>(SrcDesc + 1 );
142
139
auto *DstDesc = reinterpret_cast <InlineDescriptor *>(DstPtr);
143
140
auto *DstElemLoc = reinterpret_cast <std::byte *>(DstDesc + 1 );
144
141
@@ -233,7 +230,7 @@ static void dtorRecord(Block *B, std::byte *Ptr, const Descriptor *D) {
233
230
destroyBase (B, Ptr, F.Desc , F.Offset );
234
231
}
235
232
236
- static void moveRecord (Block *B, const std::byte *Src, std::byte *Dst,
233
+ static void moveRecord (Block *B, std::byte *Src, std::byte *Dst,
237
234
const Descriptor *D) {
238
235
assert (D);
239
236
assert (D->ElemRecord );
0 commit comments