Changeset 17521 in josm for trunk/src/org


Ignore:
Timestamp:
2021-02-22T00:40:49+01:00 (4 years ago)
Author:
Don-vip
Message:

spotbugs - SBSC_USE_STRINGBUFFER_CONCATENATION

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/io/UploadDialog.java

    r17339 r17521  
    2020import java.util.Collections;
    2121import java.util.HashMap;
     22import java.util.LinkedHashSet;
    2223import java.util.List;
    2324import java.util.Locale;
     
    2526import java.util.Map.Entry;
    2627import java.util.Optional;
     28import java.util.Set;
    2729import java.util.stream.Collectors;
    2830
     
    345347     */
    346348    private static String getCommentWithDataSetHashTag(String comment, DataSet dataSet) {
    347         String result = comment;
     349        StringBuilder result = new StringBuilder(comment);
    348350        if (dataSet != null) {
    349351            String hashtags = dataSet.getChangeSetTags().get("hashtags");
    350352            if (hashtags != null) {
     353                Set<String> sanitizedHashtags = new LinkedHashSet<>();
    351354                for (String hashtag : hashtags.split(";", -1)) {
    352                     String sanitizedHashtag = hashtag.startsWith("#") ? hashtag : "#" + hashtag;
    353                     if (!result.contains(sanitizedHashtag)) {
    354                         result = result + " " + sanitizedHashtag;
    355                     }
     355                    sanitizedHashtags.add(hashtag.startsWith("#") ? hashtag : "#" + hashtag);
    356356                }
    357             }
    358         }
    359         return result;
     357                if (!sanitizedHashtags.isEmpty()) {
     358                    result.append(' ').append(String.join(" ", sanitizedHashtags));
     359                }
     360            }
     361        }
     362        return result.toString();
    360363    }
    361364
Note: See TracChangeset for help on using the changeset viewer.