(fs) Avoid redundant HashMap.containsKey call in MimeTypesFileTypeDetector.putIfAbsent

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P5
    • 19
    • Affects Version/s: None
    • Component/s: core-libs
    • b26

      Only non-null values are put into Map<String,String> mimeTypeMap. It means, we can replace containsKey+put calls with single putIfAbsent call. It makes code a bit cleaner and faster.

       private void putIfAbsent(String key, String value) {
           if (key != null && !key.isEmpty() &&
               value != null && !value.isEmpty() &&
               !mimeTypeMap.containsKey(key))
           {
               mimeTypeMap.put(key, value);
           }
       }

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

              Created:
              Updated:
              Resolved: