@@ -377,40 +377,43 @@ private final String _collectUntilTag() throws XMLStreamException
377
377
return "" ;
378
378
}
379
379
380
- String text = null ;
380
+ CharSequence chars = null ;
381
381
while (true ) {
382
382
switch (_xmlReader .next ()) {
383
- case XMLStreamConstants .START_ELEMENT :
384
- return (text == null ) ? "" : text ;
385
-
386
- case XMLStreamConstants .END_ELEMENT :
387
- case XMLStreamConstants .END_DOCUMENT :
388
- // 04-May-2018, tatu: For 3.0 we can actually start exposing <tag></tag> ALSO
389
- // as `null`, as long as we default `String` null handling to coerce that to
390
- // "empty"
391
- if (text == null ) {
392
- if (FromXmlParser .Feature .EMPTY_ELEMENT_AS_NULL .enabledIn (_formatFeatures )) {
393
- return null ;
383
+ case XMLStreamConstants .START_ELEMENT :
384
+ return chars == null ? "" : chars .toString ();
385
+
386
+ case XMLStreamConstants .END_ELEMENT :
387
+ case XMLStreamConstants .END_DOCUMENT :
388
+ // 04-May-2018, tatu: For 3.0 we can actually start exposing <tag></tag> ALSO
389
+ // as `null`, as long as we default `String` null handling to coerce that to
390
+ // "empty"
391
+ if (chars == null ) {
392
+ if (FromXmlParser .Feature .EMPTY_ELEMENT_AS_NULL .enabledIn (_formatFeatures )) {
393
+ return null ;
394
+ }
395
+ return "" ;
394
396
}
395
- return "" ;
396
- }
397
- return text ;
397
+ return chars .toString ();
398
398
399
- // note: SPACE is ignorable (and seldom seen), not to be included
400
- case XMLStreamConstants .CHARACTERS :
401
- case XMLStreamConstants .CDATA :
402
- // 17-Jul-2017, tatu: as per [dataformat-xml#236], need to try to...
399
+ // note: SPACE is ignorable (and seldom seen), not to be included
400
+ case XMLStreamConstants .CHARACTERS :
401
+ case XMLStreamConstants .CDATA :
402
+ // 17-Jul-2017, tatu: as per [dataformat-xml#236], need to try to...
403
403
{
404
404
String str = _getText (_xmlReader );
405
- if (text == null ) {
406
- text = str ;
407
- } else {
408
- text += str ;
405
+ if (chars == null ) {
406
+ chars = str ;
407
+ } else {
408
+ if (chars instanceof String ) {
409
+ chars = new StringBuilder (chars );
410
+ }
411
+ ((StringBuilder )chars ).append (str );
409
412
}
410
413
}
411
414
break ;
412
- default :
413
- // any other type (proc instr, comment etc) is just ignored
415
+ default :
416
+ // any other type (proc instr, comment etc) is just ignored
414
417
}
415
418
}
416
419
}
0 commit comments