Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8102488

Remove unnecessary method calls and other optimizations to Parent

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 8
    • None
    • javafx

      There are a number of simple optimizations to be made to parent, applicable to both JIT and non-JIT situations but especially true for either startup (before code is JIT'ed) or non-JIT situations. For example code such as:

      if (getParent() != null) {
          getParent().doSomething();
      }

      Is quite prevalent in the code and can be simply optimized by a single call to getParent (which incidentally I do not believe gets fully inlined via JIT due to the fact that a property object is being used here).

      In addition, the getManagedChildren() method is horrible in that it creates a new Array and populates it each time. Instead, we should cache a single unmodifiable list and throw it out whenever children are added / removed / managed state changes, but otherwise have a cache we can return the next time we're asked. This is important because in layout we often call this multiple times (see HBox for example).

      Some other optimizations include changing from enhanced for loop (and temporary iterator creation) to old school for loops, and other such techniques.

            rbair Richard Bair (Inactive)
            rbair Richard Bair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: