This is an automated email from the ASF dual-hosted git repository.

jackie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git


The following commit(s) were added to refs/heads/master by this push:
     new 0e49e74  use StandardCharsets.UTF_8 which is faster than looking up 
the charset and doesn't need to handle excetions (#7599)
0e49e74 is described below

commit 0e49e74afc0798708b4e27f8a6b08a06da03a042
Author: Richard Startin <[email protected]>
AuthorDate: Thu Oct 21 00:23:14 2021 +0100

    use StandardCharsets.UTF_8 which is faster than looking up the charset and 
doesn't need to handle excetions (#7599)
---
 .../org/apache/pinot/spi/utils/StringUtils.java    | 22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git 
a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java 
b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java
index abc195c..4d7bbeb 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/StringUtils.java
@@ -18,36 +18,22 @@
  */
 package org.apache.pinot.spi.utils;
 
-import java.io.UnsupportedEncodingException;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 
 public class StringUtils {
   private StringUtils() {
   }
 
-  private static final String UTF_8 = "UTF-8";
-
   public static byte[] encodeUtf8(String s) {
-    try {
-      // NOTE: Intentionally use charset name to reuse the string encoder
-      //noinspection CharsetObjectCanBeUsed
-      return s.getBytes(UTF_8);
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
+    return s.getBytes(UTF_8);
   }
 
   public static String decodeUtf8(byte[] bytes) {
-    return decodeUtf8(bytes, 0, bytes.length);
+    return new String(bytes, UTF_8);
   }
 
   public static String decodeUtf8(byte[] bytes, int offset, int length) {
-    try {
-      // NOTE: Intentionally use charset name to reuse the string encoder
-      //noinspection CharsetObjectCanBeUsed
-      return new String(bytes, offset, length, UTF_8);
-    } catch (UnsupportedEncodingException e) {
-      throw new RuntimeException(e);
-    }
+    return new String(bytes, offset, length, UTF_8);
   }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to