Skip to content

Remove no longer needed optimization #22942

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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