Skip to content

Commit

Permalink
Remove no longer needed optimization
Browse files Browse the repository at this point in the history
Since FasterXML/jackson-core#1081 this optimization
does no longer make sense as it's applied internally by Jackson if needed.
  • Loading branch information
wendigo committed Aug 6, 2024
1 parent caa0bbd commit 89cd867
Showing 1 changed file with 0 additions and 11 deletions.
11 changes: 0 additions & 11 deletions core/trino-main/src/main/java/io/trino/util/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.StringReader;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -106,9 +105,6 @@

public final class JsonUtil
{
// StringReader outperforms InputStreamReader for small inputs. Limit based on Jackson benchmarks {@link https://github.com/FasterXML/jackson-benchmarks/pull/9}
private static final int STRING_READER_LENGTH_LIMIT = 8192;

private JsonUtil() {}

// This object mapper is constructed without .configure(ORDER_MAP_ENTRIES_BY_KEYS, true) because
Expand All @@ -127,13 +123,6 @@ public static JsonFactory createJsonFactory()
public static JsonParser createJsonParser(JsonFactory factory, Slice json)
throws IOException
{
// Jackson tries to detect the character encoding automatically when using InputStream
// so we pass StringReader or an InputStreamReader instead.
if (json.length() < STRING_READER_LENGTH_LIMIT) {
// StringReader is more performant than InputStreamReader for small inputs
return factory.createParser(new StringReader(new String(json.getBytes(), UTF_8)));
}

return factory.createParser(new InputStreamReader(json.getInput(), UTF_8));
}

Expand Down

0 comments on commit 89cd867

Please sign in to comment.