1
0
mirror of https://github.com/mfontanini/libtins synced 2026-01-23 02:35:57 +01:00

Performance improvements

* Remove option size memers on IP/TCP and instead calculate
these when they're needed
* Reorder members on IP/TCP so as to remove/decrease padding
* Move most memory helpers impl into header file so they
can be inlined
* Make PDUOption's move ctor/assignment operator noexcept
This commit is contained in:
Matias Fontanini
2017-05-13 16:21:18 -07:00
parent cedd127e8f
commit 7250c7a03d
7 changed files with 131 additions and 157 deletions

View File

@@ -523,7 +523,6 @@ public:
* \param opt The option to be added.
*/
void add_option(option &&opt) {
internal_add_option(opt);
options_.push_back(std::move(opt));
}
@@ -538,7 +537,6 @@ public:
template<typename... Args>
void add_option(Args&&... args) {
options_.emplace_back(std::forward<Args>(args)...);
internal_add_option(options_.back());
}
#endif
@@ -756,7 +754,8 @@ private:
void tot_len(uint16_t new_tot_len);
void prepare_for_serialize();
void internal_add_option(const option& option);
uint32_t calculate_options_size() const;
uint32_t pad_options_size(uint32_t size) const;
void init_ip_fields();
void write_serialization(uint8_t* buffer, uint32_t total_sz);
void write_option(const option& opt, Memory::OutputMemoryStream& stream);
@@ -765,11 +764,9 @@ private:
void checksum(uint16_t new_check);
options_type::const_iterator search_option_iterator(option_identifier id) const;
options_type::iterator search_option_iterator(option_identifier id);
void update_padded_options_size();
ip_header header_;
uint16_t options_size_, padded_options_size_;
options_type options_;
ip_header header_;
};
} // Tins