You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ce...@apache.org on 2015/10/26 21:48:32 UTC
svn commit: r1710692 -
/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
Author: centic
Date: Mon Oct 26 20:48:32 2015
New Revision: 1710692
URL: http://svn.apache.org/viewvc?rev=1710692&view=rev
Log:
Apply some micro-optimization which helps when retrieving the string-value of large spreadsheets
Modified:
poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java?rev=1710692&r1=1710691&r2=1710692&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFRichTextString.java Mon Oct 26 20:48:32 2015
@@ -315,7 +315,7 @@ public class XSSFRichTextString implemen
if(st.sizeOfRArray() == 0) {
return utfDecode(st.getT());
}
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
for(CTRElt r : st.getRArray()){
buf.append(r.getT());
}
@@ -502,7 +502,7 @@ public class XSSFRichTextString implemen
static String utfDecode(String value){
if(value == null) return null;
- StringBuffer buf = new StringBuffer();
+ StringBuilder buf = new StringBuilder();
Matcher m = utfPtrn.matcher(value);
int idx = 0;
while(m.find()) {
@@ -517,6 +517,13 @@ public class XSSFRichTextString implemen
idx = m.end();
}
+
+ // small optimization: don't go via StringBuilder if not necessary,
+ // the encodings are very rare, so we should almost always go via this shortcut.
+ if(idx == 0) {
+ return value;
+ }
+
buf.append(value.substring(idx));
return buf.toString();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org