@@ -56,7 +56,7 @@ impl<'de> Deserializer<'de> {
56
56
pub fn parse_str_ ( & mut self ) -> Result < & ' de str > {
57
57
// Add 1 to skip the initial "
58
58
let idx = self . iidx + 1 ;
59
- // let mut padding = [0u8; 32];
59
+ let mut padding = [ 0u8 ; 32 ] ;
60
60
//let mut read: usize = 0;
61
61
62
62
// we include the terminal '"' so we know where to end
@@ -69,7 +69,19 @@ impl<'de> Deserializer<'de> {
69
69
loop {
70
70
// store to dest unconditionally - we can overwrite the bits we don't like
71
71
// later
72
- let ParseStringHelper { bs_bits, quote_bits } = unsafe { find_bs_bits_and_quote_bits ( & src[ src_i..] , None ) } ;
72
+
73
+ let srcx = if src. len ( ) >= src_i + 32 {
74
+ & src[ src_i..]
75
+ } else {
76
+ unsafe {
77
+ padding
78
+ . get_unchecked_mut ( ..src. len ( ) - src_i)
79
+ . clone_from_slice ( src. get_unchecked ( src_i..) ) ;
80
+ & padding
81
+ }
82
+ } ;
83
+
84
+ let ParseStringHelper { bs_bits, quote_bits } = unsafe { find_bs_bits_and_quote_bits ( & srcx, None ) } ;
73
85
74
86
if ( bs_bits. wrapping_sub ( 1 ) & quote_bits) != 0 {
75
87
// we encountered quotes first. Move dst to point to quotes and exit
@@ -111,9 +123,20 @@ impl<'de> Deserializer<'de> {
111
123
let dst: & mut [ u8 ] = & mut self . strings ;
112
124
113
125
loop {
126
+ let srcx = if src. len ( ) >= src_i + 32 {
127
+ & src[ src_i..]
128
+ } else {
129
+ unsafe {
130
+ padding
131
+ . get_unchecked_mut ( ..src. len ( ) - src_i)
132
+ . clone_from_slice ( src. get_unchecked ( src_i..) ) ;
133
+ & padding
134
+ }
135
+ } ;
136
+
114
137
// store to dest unconditionally - we can overwrite the bits we don't like
115
138
// later
116
- let ParseStringHelper { bs_bits, quote_bits } = unsafe { find_bs_bits_and_quote_bits ( & src [ src_i.. ] , Some ( & mut dst[ dst_i.. ] ) ) } ;
139
+ let ParseStringHelper { bs_bits, quote_bits } = unsafe { find_bs_bits_and_quote_bits ( & srcx , Some ( dst) ) } ;
117
140
118
141
if ( bs_bits. wrapping_sub ( 1 ) & quote_bits) != 0 {
119
142
// we encountered quotes first. Move dst to point to quotes and exit
0 commit comments