refactor(smudge): Replace custom doubly linked list with std::deque in W3DSmudge - #3021
refactor(smudge): Replace custom doubly linked list with std::deque in W3DSmudge#3021stephanmeesters wants to merge 5 commits into
Conversation
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Include/GameClient/Smudge.h | Replaces intrusive-list inheritance and members with typed deque aliases and container-derived counting. |
| Core/GameEngine/Source/GameClient/System/Smudge.cpp | Converts smudge lifecycle and object-pool operations to equivalent deque operations. |
| Core/GameEngineDevice/Source/W3DDevice/GameClient/W3DSmudge.cpp | Converts rendering and batching traversal from linked nodes to deque iterators. |
Reviews (3): Last reviewed commit: "Process review comments #2" | Re-trigger Greptile
Caball009
left a comment
There was a problem hiding this comment.
AFAIK MSVC's implementation of std::deque uses a very low bucket size, so I don't think we'll get a free performance boost that way, unfortunately.
| while (!m_freeSmudgeSetList.empty()) { | ||
| head = m_freeSmudgeSetList.front(); | ||
| m_freeSmudgeSetList.pop_front(); | ||
| delete head; | ||
| } |
There was a problem hiding this comment.
Could also delete while iterating and then clear the container outside the loop. I'm a little fuzzy on the internals of std::deque, so I'm a bit doubtful this would be a performance improvement.
There was a problem hiding this comment.
Decided to keep this one for readability, unfortunately vc6 can't do the short hand for-loop
| SmudgeQueue& smudgeList = (*setIt)->getUsedSmudgeList(); | ||
|
|
||
| for (; smudge; smudge=smudge->Succ()) | ||
| while (remainingSmudge != smudgeList.end()) |
There was a problem hiding this comment.
Better: for (; remainingSmudge != smudgeList.end(); ++remainingSmudge)
| set=m_usedSmudgeSetList.Head(); //first smudge set that needs rendering. | ||
| Smudge *remainingSmudgeStart=set->getUsedSmudgeList().Head(); //first smudge that needs rendering. | ||
| setIt=m_usedSmudgeSetList.begin(); //first smudge set that needs rendering. | ||
| SmudgeQueue::iterator remainingSmudge = (*setIt)->getUsedSmudgeList().begin(); //first smudge that needs rendering. |
| } | ||
|
|
||
| while (set) | ||
| while (setIt != m_usedSmudgeSetList.end()) |
There was a problem hiding this comment.
Or for (; setIt != m_usedSmudgeSetList.end(); ++setIt)
|
|
||
| while ((head = m_usedSmudgeList.Head ()) != nullptr) { | ||
| m_usedSmudgeList.Remove_Head (); | ||
| m_freeSmudgeList.Add_Head(head); //add to free list |
There was a problem hiding this comment.
comment was removed here, but kept at other places
| static SmudgeQueue m_freeSmudgeList; ///<list of unused smudges for use by SmudgeSets. | ||
| }; | ||
|
|
||
| typedef std::deque<SmudgeSet*> SmudgeSetQueue; |
| smudgeVertex m_verts[5]; //5 vertices of this smudge (in counter-clockwise order, starting at top-left, ending in center.) | ||
| }; | ||
|
|
||
| typedef std::deque<Smudge*> SmudgeQueue; |
DLListClassusages inW3DSmudgewithstd::deque.std::dequewas chosen instead ofstd::listbecause we only needed removals/insertions at the front/back (no splicing).m_usedSmudgeCountwith the queue's size