aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2024-02-03 20:20:40 +0000
committerPJ Fanning <fanningpj@apache.org>2024-02-03 20:20:40 +0000
commite45579801975c995bd846f41f9318cc11b56ffb3 (patch)
tree66b783e5d135833376140072b1f2a4ffc0d68118
parente0d446c533c4d2d7d2b248eeb631402620233644 (diff)
downloadpoi-e45579801975c995bd846f41f9318cc11b56ffb3.tar.gz
poi-e45579801975c995bd846f41f9318cc11b56ffb3.zip
remove one use of CodepointsUtil.iteratorFor
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1915571 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java16
1 files changed, 11 insertions, 5 deletions
diff --git a/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java b/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
index e87343d9f2..879884d4a5 100644
--- a/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
+++ b/poi/src/main/java/org/apache/poi/ss/format/CellFormatPart.java
@@ -573,11 +573,17 @@ public class CellFormatPart {
* @return The character repeated three times.
*/
static String expandChar(String part) {
- List<String> codePoints = new ArrayList<>();
- CodepointsUtil.iteratorFor(part).forEachRemaining(codePoints::add);
- if (codePoints.size() < 2) throw new IllegalArgumentException("Expected part string to have at least 2 chars");
- String ch = codePoints.get(1);
- return ch + ch + ch;
+ PrimitiveIterator.OfInt iterator = CodepointsUtil.primitiveIterator(part);
+ Integer c0 = iterator.hasNext() ? iterator.next() : null;
+ Integer c1 = iterator.hasNext() ? iterator.next() : null;
+ if (c0 == null || c1 == null)
+ throw new IllegalArgumentException("Expected part string to have at least 2 chars");
+ char[] ch = Character.toChars(c1);
+ StringBuilder sb = new StringBuilder(ch.length * 3);
+ sb.append(ch);
+ sb.append(ch);
+ sb.append(ch);
+ return sb.toString();
}
/**