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

Avoid creating new Booleans for increased operational speed

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 1.2.0, 1.4.0
    • Fix Version/s: 1.4.0
    • Component/s: other-libs
    • Labels:
    • Subcomponent:
    • Resolved In Build:
      beta
    • CPU:
      generic, x86
    • OS:
      generic, windows_nt

      Description



      Name: krT82822 Date: 08/13/99


      This isn't really a feature request, more of an optimization
      request. Its also closely related to bug #4206052

      There is no need for more than two instances of Boolean
      at any time during the life of the VM. They are of course
      Boolean.TRUE and Boolean.FALSE. A quick search for the string
      "new Boolean" turned up several dozen instances where Java creates
      a new object when a simple TRUE or FALSE would do.

      In general:

      - "new Boolean(true)" & "new Boolean(false)" should be replaced
        with "Boolean.TRUE" & "Boolean.FALSE" respectively.
      - "new Boolean(b)" where b is a boolean expression should be
        replaced with "b ? Boolean.TRUE : Boolean.FALSE".
      - "new Boolean(s)" where s is a String should be replaced with
        "Boolean.valueOf(s)", especially if the improvements listed
        in bug #4206052 are implemented.

      If these improvements are made you will see an increase in speed
      since no object needs to be created and a lighter load on the
      garbage collector due to fewer objects.
      (Review ID: 93906)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              stewilso Steve Wilson (Inactive)
              Reporter:
              kryansunw Kevin Ryan (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: