@@ -60,16 +60,16 @@ class ProfOStream {
60
60
// \c patch can only be called when all data is written and flushed.
61
61
// For raw_string_ostream, the patch is done on the target string
62
62
// directly and it won't be reflected in the stream's internal buffer.
63
- void patch (PatchItem *P, int NItems ) {
63
+ void patch (ArrayRef< PatchItem> P ) {
64
64
using namespace support ;
65
65
66
66
if (IsFDOStream) {
67
67
raw_fd_ostream &FDOStream = static_cast <raw_fd_ostream &>(OS);
68
68
const uint64_t LastPos = FDOStream.tell ();
69
- for (int K = 0 ; K < NItems; K++ ) {
70
- FDOStream.seek (P[K] .Pos );
71
- for (int I = 0 ; I < P[K] .N ; I++)
72
- write (P[K] .D [I]);
69
+ for (const auto &K : P ) {
70
+ FDOStream.seek (K .Pos );
71
+ for (int I = 0 ; I < K .N ; I++)
72
+ write (K .D [I]);
73
73
}
74
74
// Reset the stream to the last position after patching so that users
75
75
// don't accidentally overwrite data. This makes it consistent with
@@ -78,11 +78,11 @@ class ProfOStream {
78
78
} else {
79
79
raw_string_ostream &SOStream = static_cast <raw_string_ostream &>(OS);
80
80
std::string &Data = SOStream.str (); // with flush
81
- for (int K = 0 ; K < NItems; K++ ) {
82
- for (int I = 0 ; I < P[K] .N ; I++) {
81
+ for (const auto &K : P ) {
82
+ for (int I = 0 ; I < K .N ; I++) {
83
83
uint64_t Bytes =
84
- endian::byte_swap<uint64_t , llvm::endianness::little>(P[K] .D [I]);
85
- Data.replace (P[K] .Pos + I * sizeof (uint64_t ), sizeof (uint64_t ),
84
+ endian::byte_swap<uint64_t , llvm::endianness::little>(K .D [I]);
85
+ Data.replace (K .Pos + I * sizeof (uint64_t ), sizeof (uint64_t ),
86
86
(const char *)&Bytes, sizeof (uint64_t ));
87
87
}
88
88
}
@@ -575,7 +575,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
575
575
{MemProfSectionStart + sizeof (uint64_t ), &FramePayloadOffset, 1 },
576
576
{MemProfSectionStart + 2 * sizeof (uint64_t ), &FrameTableOffset, 1 },
577
577
};
578
- OS.patch (PatchItems, 3 );
578
+ OS.patch (PatchItems);
579
579
}
580
580
581
581
// BinaryIdSection has two parts:
@@ -693,7 +693,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
693
693
{CSSummaryOffset, reinterpret_cast <uint64_t *>(TheCSSummary.get ()),
694
694
(int )CSSummarySize}};
695
695
696
- OS.patch (PatchItems, std::size (PatchItems) );
696
+ OS.patch (PatchItems);
697
697
} else {
698
698
// Now do the final patch:
699
699
PatchItem PatchItems[] = {
@@ -713,7 +713,7 @@ Error InstrProfWriter::writeImpl(ProfOStream &OS) {
713
713
{CSSummaryOffset, reinterpret_cast <uint64_t *>(TheCSSummary.get ()),
714
714
(int )CSSummarySize}};
715
715
716
- OS.patch (PatchItems, std::size (PatchItems) );
716
+ OS.patch (PatchItems);
717
717
}
718
718
719
719
for (const auto &I : FunctionData)
0 commit comments