commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r1089724 - /commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
Date Thu, 07 Apr 2011 04:03:55 GMT
Author: bayard
Date: Thu Apr  7 04:03:55 2011
New Revision: 1089724

URL: http://svn.apache.org/viewvc?rev=1089724&view=rev
Log:
Implemented the native CharSequence version of toCharArray

Modified:
    commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java

Modified: commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java
URL: http://svn.apache.org/viewvc/commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java?rev=1089724&r1=1089723&r2=1089724&view=diff
==============================================================================
--- commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java (original)
+++ commons/proper/lang/trunk/src/main/java/org/apache/commons/lang3/StringUtils.java Thu
Apr  7 04:03:55 2011
@@ -6489,8 +6489,12 @@ public class StringUtils {
         if (cs instanceof String) {
             return ((String) cs).toCharArray();
         } else {
-            // TODO: Implement rather than convert to String
-            return cs.toString().toCharArray();
+            int sz = cs.length();
+            char[] array = new char[cs.length()];
+            for (int i=0; i < sz; i++) {
+                array[i] = cs.charAt(i);
+            }
+            return array;
         }
     }
 



Mime
View raw message