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

Use move semantics in inventory::add_item() #55100

Merged
merged 1 commit into from
Feb 4, 2022

Conversation

BrettDong
Copy link
Member

Summary

None

Purpose of change

When profiling #55099 I noticed some excessive item copy construction showing up on the call tree.

Describe the solution

When adding an item to character inventory, move construct rather than copy construct the new item.

Describe alternatives you've considered

Testing

Reduces 2 seconds in starting_items test with this simple change.

Additional context

@BrettDong BrettDong added [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones labels Feb 4, 2022
@github-actions github-actions bot added json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels Feb 4, 2022
@mqrause
Copy link
Contributor

mqrause commented Feb 4, 2022

If it's this noticeable for starting_items, it should have a significant effect on crafting_inventory, too.

@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Feb 4, 2022
@kevingranade kevingranade merged commit 0e70699 into CleverRaven:master Feb 4, 2022
@BrettDong BrettDong deleted the inventory branch February 5, 2022 13:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions [C++] Changes (can be) made in C++. Previously named `Code` Code: Performance Performance boosting code (CPU, memory, etc.) Inventory / AIM / Zones Inventory, Advanced Inventory Management or Zones json-styled JSON lint passed, label assigned by github actions
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants