Skip to content

Commit

Permalink
#123 fix code review issues
Browse files Browse the repository at this point in the history
- do not size underlying 'struct FILE' when footprinting FILE* pointer
- simplify queue serialization to avoid copying
- fix grammar typo
  • Loading branch information
cz4rs committed Sep 15, 2020
1 parent 4452399 commit 5c7a3ee
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 34 deletions.
33 changes: 5 additions & 28 deletions src/checkpoint/container/queue_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,51 +52,28 @@
namespace checkpoint {

template <typename Serializer, typename T>
void serialize(Serializer& s, std::queue<T> q) {
void serialize(Serializer& s, const std::queue<T>& q) {
serializeQueue(s, q);
}

template <
typename SerializerT,
typename T,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
>
>
void serializeQueue(SerializerT& s, std::queue<T> q) {
s.countBytes(q);
while (not q.empty())
{
s | q.front();
q.pop();
}
}

template <typename Serializer, typename T>
void serialize(Serializer& s, std::priority_queue<T> q) {
void serialize(Serializer& s, const std::priority_queue<T>& q) {
serializeQueue(s, q);
}

template <
typename SerializerT,
typename T,
typename Q,
typename = std::enable_if_t<
std::is_same<
SerializerT,
checkpoint::Footprinter
>::value
>
>
void serializeQueue(SerializerT& s, std::priority_queue<T> q) {
void serializeQueue(SerializerT& s, const Q& q) {
s.countBytes(q);
while (not q.empty())
{
s | q.top();
q.pop();
}
s.contiguousBytes(nullptr, sizeof(typename Q::value_type), q.size());
}

} /* end namespace checkpoint */
Expand Down
7 changes: 2 additions & 5 deletions src/checkpoint/container/raw_ptr_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ void serializeRawPtr(SerializerT& s, T* ptr) {
/**
* \brief Serialize FILE pointer \c ptr
*
* Only footprinting mode is supported at the moment. Counts the pointer and
* pointee (underlying struct) size without following it.
* Only footprinting mode is supported at the moment. Counts the pointer size
* without following it.
*
* \param[in] serializer serializer to use
* \param[in] ptr pointer to serialize
Expand All @@ -106,9 +106,6 @@ template <
>
void serializeFilePtr(SerializerT& s, FILE* ptr) {
s.countBytes(ptr);
if (ptr != nullptr) {
s.countBytes(*ptr);
}
}

} /* end namespace checkpoint */
Expand Down
2 changes: 1 addition & 1 deletion src/checkpoint/container/string_serialize.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void serializeStringMeta(Serializer& s, std::string& str) {
/**
* \brief Serialize string \c str
*
* Resizes a string to it's actual size and serializes it.
* Resizes a string to its actual size and serializes it.
* Note: footprinting mode does not detect small string optimization, so
* a limited overcount is possible.
*
Expand Down

0 comments on commit 5c7a3ee

Please sign in to comment.