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

(prefs) Improve the performance of java.util.prefs.AbstractPreferences.isUserNode()

XMLWordPrintable

    • b03
    • generic
    • generic
    • Not verified

      From the java.lang.Boolean(boolean) API:
      "It is rarely appropriate to use this constructor. Unless a new instance is required, the static factory valueOf(boolean) is generally a better choice. It is likely to yield significantly better space and time performance."

      Boolean objects are immutable, but method java.util.prefs.AbstractPreferences.isUserNode() still uses the Constructor rather than the static method.

         public boolean isUserNode() {
              Boolean result = (Boolean)
                AccessController.doPrivileged( new PrivilegedAction() {
                  public Object run() {
                      return new Boolean(root == Preferences.userRoot()); // <--- here
                  }
              });
              return result.booleanValue();
          }

      ###@###.### 2005-03-21 11:46:44 GMT

            sherman Xueming Shen
            jloefflm Johann Löfflmann (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: