[http_server] Simplify DRT node and table #132
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When I see the
std::vecotr<std::shared_ptr<drt_node>>
andstd::vector<std::shared_ptr<std::string>>
as thedrt_node
anddynamic_routing_table
's members respectively, I cannot help wondering why theshared_ptr<T>
are needed here. Later I realized the instance of the DRT table is allowed to copy therefore we need to keep its objects being shared across all instances. Somehow I still think it is a waste to haveshared_ptr<T>
manage each small object.This PR is to have:
unordered_set<string>
to keep the strings other thanstd::vector<std::shared_ptr<std::string>>
.unordered_set<string>
is more straightforward and able to get of redundant duplicates automatically.drt_node_pool
wrapping thevector<unique_ptr<drt_node>>
and its instance is shared across all instances ofdrt_node
to manage the lifetime of new drt_node instances.dynamic_routing_table
is the only place to hold oneshared_ptr<dynamic_routing_table_impl>
and thedynamic_routing_table_impl
is the previous implementation. therefore we only have one shared_ptr to manage one big object.Will post this PR as draft to let @matt-42 have a review first. Will squash to one single commit before final merge.