Repository navigation
RetransmissionBuffer: Avoid needless allocations when storing and removing items - #1997
Conversation
…emoving items - `FillItem()` is replaced with `CreateItem()`, which constructs the item in place instead of default constructing it and assigning its members afterwards. - `Clear()` and `RemoveOldest()` no longer call `Item::Reset()` before deleting the item. `~Item()` already destroys `sharedPacket` (which is what decreases the RTP packet shared pointer counter), so the call was redundant. Worse, `Item::Reset()` does not reset the item in place but replaces `sharedPacket` with a newly constructed one, allocating yet another shared state just to destroy it immediately after.
ibc
left a comment
There was a problem hiding this comment.
Do we need the Item::Reset() method or can we remove it?
We don't. Only used in tests, I already commented this in the past. I'll remove it here. |
Does |
It does not. There's no reason to test something that is never used. |
|
Indeed I though you were referring to |
Ok some trick applies there. |
FillItem()is replaced withCreateItem(), which constructs the item in place instead of default constructing it and assigning its members afterwards.Clear()andRemoveOldest()no longer callItem::Reset()before deleting the item.~Item()already destroyssharedPacket(which is what decreases the RTP packet shared pointer counter), so the call was redundant. Worse,Item::Reset()does not reset the item in place but replacessharedPacketwith a newly constructed one, allocating yet another shared state just to destroy it immediately after.