-
Notifications
You must be signed in to change notification settings - Fork 121
Use move for std::vector instead of copying in path functions #1895
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
base: main
Are you sure you want to change the base?
Changes from all commits
6684d6e
17353e6
0d9caa1
315d16f
e951e6c
2a5e8f8
fae8029
69c373c
63ff05f
e75fb44
87948f9
e97db76
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -420,7 +420,7 @@ struct AICommandParms | |
| Object* m_obj; | ||
| Object* m_otherObj; | ||
| const Team* m_team; | ||
| std::vector<Coord3D> m_coords; | ||
| mutable std::vector<Coord3D> m_coords; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After thinking about this more, let us do a lightweight refactor and only touch where we can easily avoid a copy without const_casts or mutables. Then also close #1924
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, so close 1924, and close this, and make another PR? Which changes do we want? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove the mutable and then keep the copies where it would fail to compile. |
||
| const Waypoint* m_waypoint; | ||
| const PolygonTrigger* m_polygon; | ||
| Int m_intValue; /// misc usage | ||
|
|
@@ -550,18 +550,18 @@ class AICommandInterface | |
| aiDoCommand(&parms); | ||
| } | ||
|
|
||
| inline void aiFollowExitProductionPath( const std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource ) | ||
| inline void aiFollowExitProductionPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource ) | ||
| { | ||
| AICommandParms parms(AICMD_FOLLOW_EXITPRODUCTION_PATH, cmdSource); | ||
| parms.m_coords = *path; | ||
| move_or_swap(parms.m_coords, *path); | ||
| parms.m_obj = ignoreObject; | ||
| aiDoCommand(&parms); | ||
| } | ||
|
|
||
| inline void aiFollowPath( const std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource ) | ||
| inline void aiFollowPath( std::vector<Coord3D>* path, Object *ignoreObject, CommandSourceType cmdSource ) | ||
| { | ||
| AICommandParms parms(AICMD_FOLLOW_PATH, cmdSource); | ||
| parms.m_coords = *path; | ||
| move_or_swap(parms.m_coords, *path); | ||
| parms.m_obj = ignoreObject; | ||
| aiDoCommand(&parms); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.