-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[10276] Use more appropriate vector container instead of list as cont…
…ainer for CreatureEventAI holders vector container provides less time to access to contained elements
- Loading branch information
Showing
3 changed files
with
17 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
#ifndef __REVISION_NR_H__ | ||
#define __REVISION_NR_H__ | ||
#define REVISION_NR "10275" | ||
#define REVISION_NR "10276" | ||
#endif // __REVISION_NR_H__ |
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SilverIce is back
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Graz, SilverIce ^^
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just wondering what the difference is and why vector is better than list for this. I don't think you're wrong, I just want to be able to understand why for the future.
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think SilverIce already provided the answer: "vector container provides less time to access to contained elements"
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, why not using typedef for collection? Thus you'll be able to change container type in one place only.
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I not sure that type change so good. This container used for (1) full loop by elements, where std::list and std::vector not expected big differences. Ok maybe small vector prio. And (2) push_back at each AI creating, where vector i think lot slower that list. Ofc, AI creating (2) more seldom event that very often loops (1) but i not sure that small speedup in (1) will in sum more that slowdown in (2)
I already do related patch.
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in vector case: not need to allocate memory for each element at each push_back call
I have never heard that vector is slower than list at puhing back ( at least for containers with small amount of elements, like here)
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in vector case vector reserve some size, so use more memory that need and if this reserve too small then reallocate all memory block with all data move from old to new... in bad case.
d899744
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vector will good for push_back if it will before this reserve exactly required data amount. So some -pre-counting need before pushs