[BGPCEP-976] Improve PCEP message parsing interface Created: 26/Jul/21 Updated: 26/Jul/21 Resolved: 26/Jul/21 |
|
| Status: | Resolved |
| Project: | bgpcep |
| Component/s: | PCEP |
| Affects Version/s: | None |
| Fix Version/s: | 0.16.2 |
| Type: | Improvement | Priority: | Medium |
| Reporter: | Robert Varga | Assignee: | Robert Varga |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
AbstractMessageParser.validate() is operating on a List<Object>, but each implementation essentially treats the list as a queue – inquiring the first object and then maybe removing it before moving on. This is problematic with ArrayList, as its remove() method shifts elements in the array, i.e. it has O(N) complexity and gets slower with increasing number of elements. An alternative would be to use a LinkedList, which has O(1) remove(), but that suffers from worse locality and memory overhead. Change the validate() method to take a Queue instead, which allows us to use an ArrayDeque – and that has O(1) operations for everything we need. |
| Comments |
| Comment by Robert Varga [ 26/Jul/21 ] |
|
Since we are in this area, let's see if we can improve type safety by having Queue<? extends DataObject>, which has two benefits:
|
| Comment by Robert Varga [ 26/Jul/21 ] |
|
Ah, it's a different Object, not java.lang.Object. |