[GitHub] [poi] pjfanning commented on a diff in pull request #443: [Bug-66532] Improve performance of SheetDataWriter

2023-03-17 Thread via GitHub


pjfanning commented on code in PR #443:
URL: https://github.com/apache/poi/pull/443#discussion_r1140652528


##
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SheetDataWriter.java:
##
@@ -397,46 +397,51 @@ protected void outputEscapedString(String s) throws 
IOException {
 return;
 }
 
-for (Iterator iter = CodepointsUtil.iteratorFor(s); 
iter.hasNext(); ) {
-String codepoint = iter.next();
+for (int i = 0; i < s.length(); i++) {
+final int codepoint = s.codePointAt(i);

Review Comment:
   loops should not increment in multiple places (ideally) - if you use the 
codePointCount for the limit of the loop then the count will be correct



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[GitHub] [poi] pjfanning commented on a diff in pull request #443: [Bug-66532] Improve performance of SheetDataWriter

2023-03-17 Thread via GitHub


pjfanning commented on code in PR #443:
URL: https://github.com/apache/poi/pull/443#discussion_r1140653374


##
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SheetDataWriter.java:
##
@@ -397,46 +397,51 @@ protected void outputEscapedString(String s) throws 
IOException {
 return;
 }
 
-for (Iterator iter = CodepointsUtil.iteratorFor(s); 
iter.hasNext(); ) {
-String codepoint = iter.next();
+for (int i = 0; i < s.length(); i++) {
+final int codepoint = s.codePointAt(i);
+
 switch (codepoint) {
-case "<":
+case 60: // <

Review Comment:
   could you test with `'<'`? - this should have similar performance but would 
be more readable



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[GitHub] [poi] pjfanning commented on a diff in pull request #443: [Bug-66532] Improve performance of SheetDataWriter

2023-03-17 Thread via GitHub


pjfanning commented on code in PR #443:
URL: https://github.com/apache/poi/pull/443#discussion_r1140652528


##
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SheetDataWriter.java:
##
@@ -397,46 +397,51 @@ protected void outputEscapedString(String s) throws 
IOException {
 return;
 }
 
-for (Iterator iter = CodepointsUtil.iteratorFor(s); 
iter.hasNext(); ) {
-String codepoint = iter.next();
+for (int i = 0; i < s.length(); i++) {
+final int codepoint = s.codePointAt(i);

Review Comment:
   loops should not increment in multiple places (ideally) - if you use the 
codePintCount for the limit of the loop then the count will be correct



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org



[GitHub] [poi] pjfanning commented on a diff in pull request #443: [Bug-66532] Improve performance of SheetDataWriter

2023-03-17 Thread via GitHub


pjfanning commented on code in PR #443:
URL: https://github.com/apache/poi/pull/443#discussion_r1140647602


##
poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SheetDataWriter.java:
##
@@ -397,46 +397,51 @@ protected void outputEscapedString(String s) throws 
IOException {
 return;
 }
 
-for (Iterator iter = CodepointsUtil.iteratorFor(s); 
iter.hasNext(); ) {
-String codepoint = iter.next();
+for (int i = 0; i < s.length(); i++) {
+final int codepoint = s.codePointAt(i);

Review Comment:
   this code is wrong - s.length() is not the number of codepoints - it is the 
number of chars - in a string.
   
   see https://www.w3resource.com/java-tutorial/string/string_codepointcount.php



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


-
To unsubscribe, e-mail: dev-unsubscr...@poi.apache.org
For additional commands, e-mail: dev-h...@poi.apache.org