@@ -3,7 +3,7 @@ use pretty_assertions::assert_eq;
3
3
use quick_xml:: escape:: { escape, unescape} ;
4
4
use quick_xml:: events:: Event ;
5
5
use quick_xml:: name:: QName ;
6
- use quick_xml:: Reader ;
6
+ use quick_xml:: { NsReader , Reader } ;
7
7
8
8
static SAMPLE : & [ u8 ] = include_bytes ! ( "../tests/documents/sample_rss.xml" ) ;
9
9
static PLAYERS : & [ u8 ] = include_bytes ! ( "../tests/documents/players.xml" ) ;
@@ -73,19 +73,18 @@ fn read_event(c: &mut Criterion) {
73
73
group. finish ( ) ;
74
74
}
75
75
76
- /// Benchmarks the `Reader::read_namespaced_event ` function with all XML well-formless
76
+ /// Benchmarks the `NsReader::read_resolved_event_into ` function with all XML well-formless
77
77
/// checks disabled (with and without trimming content of #text nodes)
78
- fn read_namespaced_event ( c : & mut Criterion ) {
79
- let mut group = c. benchmark_group ( "read_namespaced_event " ) ;
78
+ fn read_resolved_event_into ( c : & mut Criterion ) {
79
+ let mut group = c. benchmark_group ( "NsReader::read_resolved_event_into " ) ;
80
80
group. bench_function ( "trim_text = false" , |b| {
81
81
b. iter ( || {
82
- let mut r = Reader :: from_reader ( SAMPLE ) ;
82
+ let mut r = NsReader :: from_bytes ( SAMPLE ) ;
83
83
r. check_end_names ( false ) . check_comments ( false ) ;
84
84
let mut count = criterion:: black_box ( 0 ) ;
85
85
let mut buf = Vec :: new ( ) ;
86
- let mut ns_buf = Vec :: new ( ) ;
87
86
loop {
88
- match r. read_namespaced_event ( & mut buf, & mut ns_buf ) {
87
+ match r. read_resolved_event_into ( & mut buf) {
89
88
Ok ( ( _, Event :: Start ( _) ) ) | Ok ( ( _, Event :: Empty ( _) ) ) => count += 1 ,
90
89
Ok ( ( _, Event :: Eof ) ) => break ,
91
90
_ => ( ) ,
@@ -101,15 +100,14 @@ fn read_namespaced_event(c: &mut Criterion) {
101
100
102
101
group. bench_function ( "trim_text = true" , |b| {
103
102
b. iter ( || {
104
- let mut r = Reader :: from_reader ( SAMPLE ) ;
103
+ let mut r = NsReader :: from_bytes ( SAMPLE ) ;
105
104
r. check_end_names ( false )
106
105
. check_comments ( false )
107
106
. trim_text ( true ) ;
108
107
let mut count = criterion:: black_box ( 0 ) ;
109
108
let mut buf = Vec :: new ( ) ;
110
- let mut ns_buf = Vec :: new ( ) ;
111
109
loop {
112
- match r. read_namespaced_event ( & mut buf, & mut ns_buf ) {
110
+ match r. read_resolved_event_into ( & mut buf) {
113
111
Ok ( ( _, Event :: Start ( _) ) ) | Ok ( ( _, Event :: Empty ( _) ) ) => count += 1 ,
114
112
Ok ( ( _, Event :: Eof ) ) => break ,
115
113
_ => ( ) ,
@@ -393,7 +391,7 @@ purus. Consequat id porta nibh venenatis cras sed felis.";
393
391
criterion_group ! (
394
392
benches,
395
393
read_event,
396
- read_namespaced_event ,
394
+ read_resolved_event_into ,
397
395
one_event,
398
396
attributes,
399
397
escaping,
0 commit comments