Remove unnecessary Map.containsKey from GraphicsEnvironment implementations

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Unresolved
    • Priority: P5
    • None
    • Affects Version/s: None
    • Component/s: 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.

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

              Created:
              Updated: