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

Rewrite WebHistory to avoid lazy initialization when unneeded

XMLWordPrintable

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

      Richard Bair writes:
      I'm looking at WebHistory. One thing I would recommend is, when there is not a good reason for using lazy initialization of properties, then go ahead and create the properties eagerly. For example, the WebHistory currentIndex property probably should just be created eagerly since I would venture to guess that currentIndex is pretty well always used. Also, I suspect it is also true that there will only be a few WebHistory objects in existence at any given point in time, and as such, any memory savings due to lazily initialization is probably very small.

      In such cases, I prefer to just create properties eagerly because it doesn't hurt (on balance it has no real impact either way in a case like this one, but technically it will be slightly faster at runtime eager because the setter doesn't require checking whether the property is null all the time or invoking a method -- but in this case it is invoked so rarely it won't make any real difference), and because it makes the code a little simpler.

            peterz Peter Zhelezniakov
            peterz Peter Zhelezniakov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: