Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-250

BigInteger being used in range checks when a simple type would be sufficient

    XMLWordPrintable

Details

    • Improvement
    • Status: Resolved
    • Resolution: Done
    • None
    • None
    • None
    • None
    • Operating System: All
      Platform: All

    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.

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              rovarga Robert Varga
              rovarga Robert Varga
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: