Skip to content

Commit e338162

Browse files
committed
Lazy parse the header comments into string
1 parent a4a0c8f commit e338162

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

lib/stf_reader.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ namespace stf {
4242
switch(rec->getId()) {
4343
case descriptors::internal::Descriptor::STF_COMMENT:
4444
header_comments_.emplace_back(STFRecord::grabOwnership<CommentRecord>(rec));
45-
header_comments_str_.emplace_back(header_comments_.back()->getData());
4645
break;
4746
case descriptors::internal::Descriptor::STF_ISA:
4847
stf_assert(!isa_, "Header has multiple ISA records");

lib/stf_reader_base.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ namespace stf {
7676
return *trace_info_records_.back();
7777
}
7878

79+
const std::vector<std::string>& STFReaderBase::getHeaderCommentsString() {
80+
if(!header_comments_.empty() && header_comments_str_.empty()) {
81+
for(const auto& c : header_comments_) {
82+
header_comments_str_.emplace_back(c->getData());
83+
}
84+
}
85+
return header_comments_str_;
86+
}
87+
7988
int STFReaderBase::close() {
8089
version_.reset();
8190
header_comments_.clear();

stf-inc/stf_reader_base.hpp

+4-3
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,10 @@ namespace stf {
136136
return header_comments_;
137137
}
138138

139-
inline const std::vector<std::string>& getHeaderCommentsString() const {
140-
return header_comments_str_;
141-
}
139+
/**
140+
* Gets the header comments in vector type of std::string
141+
*/
142+
const std::vector<std::string>& getHeaderCommentsString();
142143

143144
/**
144145
* Returns the number of records read so far

0 commit comments

Comments
 (0)