Skip to content

Commit 4f92441

Browse files
committed
PDFBOX-5902: replace Map with List
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922540 13f79535-47bb-0310-9956-ffa450edef68
1 parent 76e1ae1 commit 4f92441

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

fontbox/src/main/java/org/apache/fontbox/cmap/CMapStrings.java

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,17 @@
1818
package org.apache.fontbox.cmap;
1919

2020
import java.nio.charset.StandardCharsets;
21-
import java.util.HashMap;
22-
import java.util.Map;
21+
import java.util.ArrayList;
22+
import java.util.List;
2323

2424
/**
2525
* Many CMaps are using the same values for the mapped strings. This class provides all common one- and two-byte
2626
* mappings to avoid duplicate strings.
2727
*/
2828
public class CMapStrings
2929
{
30-
private static final Map<Integer, String> twoByteMappings = new HashMap<>();
31-
private static final Map<Integer, String> oneByteMappings = new HashMap<>();
30+
private static final List<String> twoByteMappings = new ArrayList<>(256 * 256);
31+
private static final List<String> oneByteMappings = new ArrayList<>(256);
3232

3333
static
3434
{
@@ -47,14 +47,13 @@ private static void fillMappings()
4747
for (int j = 0; j < 256; j++)
4848
{
4949
byte[] bytes = { (byte) i, (byte) j };
50-
twoByteMappings.put(CMap.toInt(bytes),
51-
new String(bytes, StandardCharsets.UTF_16BE));
50+
twoByteMappings.add(new String(bytes, StandardCharsets.UTF_16BE));
5251
}
5352
}
5453
for (int i = 0; i < 256; i++)
5554
{
5655
byte[] bytes = { (byte) i };
57-
oneByteMappings.put(i, new String(bytes, StandardCharsets.ISO_8859_1));
56+
oneByteMappings.add(new String(bytes, StandardCharsets.ISO_8859_1));
5857
}
5958
}
6059

0 commit comments

Comments
 (0)