Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reserve space to avoid multiple allocations #1929

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

blacroc10
Copy link

std::forward ensures that the arguments are perfectly forwarded to loadScript
By reserving space in the features vector based on the size of scripts, we can avoid multiple memory allocations during the loop. If an exception occurs, returning an empty vector immediately clarifies that no scripts were loaded. Without reservation, each call to emplace_back could potentially trigger a reallocation if the current capacity is exceeded, which is costly in terms of performance. This leads to more efficient memory management and can significantly speed up the execution time when dealing with a large number of scripts.

image

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