Skip to content

Avoid frequent std::vector allocations#2

Open
dpelle wants to merge 1 commit intomapbox:masterfrom
dpelle:avoid-frequent-temporary-allocations
Open

Avoid frequent std::vector allocations#2
dpelle wants to merge 1 commit intomapbox:masterfrom
dpelle:avoid-frequent-temporary-allocations

Conversation

@dpelle
Copy link

@dpelle dpelle commented Sep 6, 2021

In my project, the most frequent dynamic allocations came from
std::vector in MinDistanceToLineSegment(...) and they can be
avoided by using a boost::container::small_vector which allocates
in the stack when there are fewer than N items. The sizeof items
is only 32 bytes, so having 64 items in small_vector uses only
2KB in the stack.

In my project, the most frequent dynamic allocations came from
std::vector in MinDistanceToLineSegment(...) and they can be
avoided by using a boost::container::small_vector which allocates
in the stack when there are fewer than N items. The sizeof items
is only 32 bytes, so having 64 items in small_vector uses only
2KB in the stack.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant