Skip to content

Commit

Permalink
PDFBOX-5902: replace Map with List
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1922540 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
lehmi committed Dec 16, 2024
1 parent 76e1ae1 commit 4f92441
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions fontbox/src/main/java/org/apache/fontbox/cmap/CMapStrings.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
package org.apache.fontbox.cmap;

import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.ArrayList;
import java.util.List;

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

static
{
Expand All @@ -47,14 +47,13 @@ private static void fillMappings()
for (int j = 0; j < 256; j++)
{
byte[] bytes = { (byte) i, (byte) j };
twoByteMappings.put(CMap.toInt(bytes),
new String(bytes, StandardCharsets.UTF_16BE));
twoByteMappings.add(new String(bytes, StandardCharsets.UTF_16BE));
}
}
for (int i = 0; i < 256; i++)
{
byte[] bytes = { (byte) i };
oneByteMappings.put(i, new String(bytes, StandardCharsets.ISO_8859_1));
oneByteMappings.add(new String(bytes, StandardCharsets.ISO_8859_1));
}
}

Expand Down

0 comments on commit 4f92441

Please sign in to comment.