mirror of https://github.com/apache/poi.git
[github-405] more performant codepoint util code. Thanks to StanBertrand. This closes #405
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1905932 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f8fd8eb2e3
commit
e9aa298e1e
|
@ -23,7 +23,7 @@ import java.util.Iterator;
|
|||
public class CodepointsUtil {
|
||||
public static Iterator<String> iteratorFor(String text) {
|
||||
return text.codePoints()
|
||||
.mapToObj(codePoint -> new StringBuilder().appendCodePoint(codePoint).toString())
|
||||
.mapToObj(codePoint -> new String(Character.toChars(codePoint)))
|
||||
.iterator();
|
||||
}
|
||||
}
|
|
@ -35,7 +35,6 @@ class TestCodepointsUtil {
|
|||
void testIterator() {
|
||||
final String unicodeSurrogates = "\uD835\uDF4A\uD835\uDF4B\uD835\uDF4C\uD835\uDF4D\uD835\uDF4E"
|
||||
+ "abcdef123456";
|
||||
Iterator<String> sci = CodepointsUtil.iteratorFor(unicodeSurrogates);
|
||||
List<String> codePoints = new ArrayList<>();
|
||||
CodepointsUtil.iteratorFor(unicodeSurrogates).forEachRemaining(codePoints::add);
|
||||
assertEquals(17, codePoints.size());
|
||||
|
|
Loading…
Reference in New Issue