From 3ef823e8e1ff4f12636fc78ab84de6042f6efd9f Mon Sep 17 00:00:00 2001 From: XenoAmess Date: Mon, 1 Jun 2020 00:48:14 +0800 Subject: [PATCH] performance improve. --- .../org/apache/commons/lang3/CharSequenceUtils.java | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java index 0d9db8e76..012a16d7b 100644 --- a/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java +++ b/src/main/java/org/apache/commons/lang3/CharSequenceUtils.java @@ -251,15 +251,7 @@ public class CharSequenceUtils { * @return the resulting char array */ static char[] toCharArray(final CharSequence cs) { - if (cs instanceof String) { - return ((String) cs).toCharArray(); - } - final int sz = cs.length(); - final char[] array = new char[cs.length()]; - for (int i = 0; i < sz; i++) { - array[i] = cs.charAt(i); - } - return array; + return cs.toString().toCharArray(); } /**