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

Remove unnecessary Map.containsKey from GraphicsEnvironment implementations

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P5 P5
    • None
    • None
    • client-libs

      There are 2 similar blocks of code in sun.awt.X11GraphicsEnvironment#initDevices

                  devices.put(id, old.containsKey(id) ? old.remove(id) :
                                                        new X11GraphicsDevice(id));

      and in sun.awt.CGraphicsEnvironment#initDevices:

                  devices.put(id, old.containsKey(id) ? old.remove(id)
                                                      : new CGraphicsDevice(id));

      We can avoid redundant Map.containsKey calls. Instead of separate containsKey call we can call old.remove and then compare result with null.

            aturbanov Andrey Turbanov
            aturbanov Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: