You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by GitBox <gi...@apache.org> on 2020/06/10 19:33:19 UTC

[GitHub] [commons-io] garydgregory commented on a change in pull request #120: Add caching for required charsets

garydgregory commented on a change in pull request #120:
URL: https://github.com/apache/commons-io/pull/120#discussion_r438360990



##########
File path: src/main/java/org/apache/commons/io/Charsets.java
##########
@@ -71,16 +83,8 @@
      * @see Charset#availableCharsets()
      * @since 2.5
      */
-    public static SortedMap<String, Charset> requiredCharsets() {
-        // maybe cache?
-        final TreeMap<String, Charset> m = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
-        m.put(StandardCharsets.ISO_8859_1.name(), StandardCharsets.ISO_8859_1);
-        m.put(StandardCharsets.US_ASCII.name(), StandardCharsets.US_ASCII);
-        m.put(StandardCharsets.UTF_16.name(), StandardCharsets.UTF_16);
-        m.put(StandardCharsets.UTF_16BE.name(), StandardCharsets.UTF_16BE);
-        m.put(StandardCharsets.UTF_16LE.name(), StandardCharsets.UTF_16LE);
-        m.put(StandardCharsets.UTF_8.name(), StandardCharsets.UTF_8);
-        return Collections.unmodifiableSortedMap(m);
+    public static Map<String, Charset> requiredCharsets() {
+        return Collections.unmodifiableSortedMap(REQUIRED_CHARSETS);

Review comment:
       Is there a reason why `REQUIRED_CHARSETS` is modifiable but not the value returned by this method?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org