[YANGTOOLS-250] BigInteger being used in range checks when a simple type would be sufficient Created: 05/Aug/14  Updated: 10/Apr/22  Resolved: 10/Mar/17

Status: Resolved
Project: yangtools
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement
Reporter: Robert Varga Assignee: Robert Varga
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: All
Platform: All


Issue Links:
Blocks
blocks MDSAL-40 Milestone: Implement Binding Specific... Resolved

 Description   

For example:

model/l2-types/target/generated-sources/sal/org/opendaylight/yang/gen/v1/urn/opendaylight/l2/types/rev130827/VlanId.java

public class VlanId
implements Serializable {

private static final List<Range<BigInteger>> _range;

public VlanId(java.lang.Integer _value) {
if (_value != null) {
BigInteger _constraint = BigInteger.valueOf(_value);
boolean isValidRange = false;
for (Range<BigInteger> r : range()) {
if (r.contains(_constraint))

{ isValidRange = true; }

}

This is clearly inefficient: we know what the allowed range/type is, so any ranges have to fit into that too – which should allow us to skip instantiation on _constraint and more importantly, use more efficient range checks.

This is a post-Helium item, because the type of _range is leaked via:

public static List<Range<BigInteger>> range()

{ return _range; }

so this constitutes a change in the binding specification.



 Comments   
Comment by Robert Varga [ 18/Mar/15 ]

For Lithium we can deprecate the public range method.

Comment by Robert Varga [ 18/Mar/15 ]

Deprecation of public methods (includes length(), which is essentially the same thing): https://git.opendaylight.org/gerrit/16780

Comment by Robert Varga [ 18/Mar/15 ]

Reschedule for Beryllium for follow-up.

Comment by Robert Varga [ 14/Jun/15 ]

https://git.opendaylight.org/gerrit/22008

Generated at Wed Feb 07 20:52:41 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.