[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:

  • the queue cannot be added to
  • it is clear that we want to have YANG-modeled objects in there
Comment by Robert Varga [ 26/Jul/21 ]

Ah, it's a different Object, not java.lang.Object.

Generated at Wed Feb 07 19:14:39 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.