perf(network): Reduce loop complexity for transport messages and remove unused static variables#2659
Conversation
7ebd8f1 to
a2267a1
Compare
|
I think it would be nice if we can change the signature of NetPacket from |
Perhaps I can just put the relevant logic from |
I think it's best to do this in a separate pull request because it involves another set of changes. |
3fe1916 to
d4f75e9
Compare
|
| Filename | Overview |
|---|---|
| Core/GameEngine/Source/GameNetwork/Transport.cpp | Most complex change: introduces shared bufferIndex in doRecv() and doSend() to avoid restarting inner scans from 0; also activates the previously-commented-out DEBUG_ASSERTCRASH for buffer-full detection. Logic is correct given m_inBuffer is always contiguously packed. |
| Core/GameEngine/Source/GameNetwork/ConnectionManager.cpp | Removes dead static counters, refactors while-loop-with-manual-increment to for-loops, and adds early break on first empty inBuffer slot. |
| Core/GameEngine/Source/GameNetwork/LANAPI.cpp | Switches loop bounds from MAX_MESSAGES to ARRAY_SIZE, preserves the !LANbuttonPushed guard, and adds early break. All LAN message types fall through to m_inBuffer[i].length = 0 outside the switch, maintaining the packed-buffer invariant. |
| Core/GameEngine/Source/GameNetwork/NAT.cpp | Adds early break and switches to ARRAY_SIZE. PROBE and KEEPALIVE packets are always cleared; unrecognised packets are not cleared (pre-existing behaviour) but remain filled and thus never trigger the early break. |
Reviews (5): Last reviewed commit: "Used '>' and '<=' instead of '==' and '!..." | Re-trigger Greptile
I can put the loop logic in another PR and put #2866 in here to replace all memory pooled uses of |
|
Whatever makes most sense. |
|
Rebased. I noticed no issues in my testing. Can be merged as far as I'm concerned. |
This PR makes modest performance improvements:
See commits for cleaner diffs.
TODO: