24
24
25
25
import com .alibaba .fastjson .JSON ;
26
26
import com .alibaba .fastjson .JSONException ;
27
+ import com .alibaba .fastjson .util .ASMUtils ;
27
28
import com .alibaba .fastjson .util .Base64 ;
28
29
29
30
//这个类,为了性能优化做了很多特别处理,一切都是为了性能!!!
@@ -167,17 +168,26 @@ public byte[] bytesValue() {
167
168
*/
168
169
public final String stringVal () {
169
170
if (!hasSpecial ) {
170
- // return new String(buf , np + 1, sp);
171
- return text . substring (np + 1 , np + 1 + sp );
171
+ //return text.substring(np + 1 , np + 1 + sp);
172
+ return this . subString (np + 1 , sp );
172
173
} else {
173
174
return new String (sbuf , 0 , sp );
174
175
}
175
176
}
176
177
177
178
public final String subString (int offset , int count ) {
178
- return text .substring (offset , offset + count );
179
+ //if (ASMUtils.isAndroid()) {
180
+ if (true ) {
181
+ char [] chars = new char [count ];
182
+ for (int i = offset ; i < offset + count ; ++i ) {
183
+ chars [i - offset ] = text .charAt (i );
184
+ }
185
+ return new String (chars );
186
+ } else {
187
+ return text .substring (offset , offset + count );
188
+ }
179
189
}
180
-
190
+
181
191
public final String numberString () {
182
192
char chLocal = charAt (np + sp - 1 );
183
193
@@ -186,8 +196,8 @@ public final String numberString() {
186
196
sp --;
187
197
}
188
198
189
- return text .substring (np , np + sp );
190
- // return new String(buf, np, sp);
199
+ // return text.substring(np, np + sp);
200
+ return this . subString ( np , sp );
191
201
}
192
202
193
203
public final int ISO8601_LEN_0 = "0000-00-00" .length ();
@@ -881,8 +891,8 @@ public Collection<String> scanFieldStringArray(char[] fieldName, Class<?> type)
881
891
for (;;) {
882
892
ch = charAt (index ++);
883
893
if (ch == '\"' ) {
884
- strVal = text . substring (start , index - 1 );
885
- // strVal = new String(buf, start, index - start - 1);
894
+ strVal = this . subString (start , index - start - 1 );
895
+ // strVal = text.substring( start, index - 1);
886
896
list .add (strVal );
887
897
ch = charAt (index ++);
888
898
break ;
0 commit comments