diff --git a/core/trino-main/src/main/java/io/trino/server/protocol/JsonEncodingUtils.java b/core/trino-main/src/main/java/io/trino/server/protocol/JsonEncodingUtils.java index 8783fc641e42..e8c8970e0a32 100644 --- a/core/trino-main/src/main/java/io/trino/server/protocol/JsonEncodingUtils.java +++ b/core/trino-main/src/main/java/io/trino/server/protocol/JsonEncodingUtils.java @@ -263,8 +263,7 @@ public void encode(JsonGenerator generator, ConnectorSession session, Block bloc return; } Slice slice = VARCHAR.getSlice(block, position); - // Optimization: avoid conversion from Slice to String and String to bytes when writing UTF-8 strings - generator.writeUTF8String(slice.byteArray(), slice.byteArrayOffset(), slice.length()); + generator.writeString(slice.toStringUtf8()); } } @@ -287,8 +286,7 @@ public void encode(JsonGenerator generator, ConnectorSession session, Block bloc return; } Slice slice = padSpaces(VARCHAR.getSlice(block, position), length); - // Optimization: avoid conversion from Slice to String and String to bytes when writing UTF-8 strings - generator.writeUTF8String(slice.byteArray(), slice.byteArrayOffset(), slice.length()); + generator.writeString(slice.toStringUtf8()); } }