File tree 2 files changed +10
-0
lines changed
2 files changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ if [ $TRAVIS_RUST_VERSION = "stable" ] || [ $TRAVIS_RUST_VERSION = "beta" ] || [
13
13
rustup default $TRAVIS_RUST_VERSION
14
14
# make sure that explicitly providing the default target works
15
15
cargo test --target x86_64-unknown-linux-gnu
16
+ cargo test --release
16
17
cargo test --features spin_threading
17
18
cargo test --features rust_threading
18
19
cargo test --features custom_time,custom_gmtime_r
Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ struct WriteTracker {
147
147
}
148
148
149
149
struct DigestAndLen {
150
+ #[ cfg( debug_assertions) ]
150
151
digest : [ u8 ; 20 ] , // SHA-1
151
152
len : usize ,
152
153
}
@@ -158,6 +159,7 @@ impl WriteTracker {
158
159
}
159
160
}
160
161
162
+ #[ cfg( debug_assertions) ]
161
163
fn digest ( buf : & [ u8 ] ) -> [ u8 ; 20 ] {
162
164
use crate :: hash:: { Md , Type } ;
163
165
let mut out = [ 0u8 ; 20 ] ;
@@ -172,9 +174,15 @@ impl WriteTracker {
172
174
Some ( pending) => {
173
175
if pending. len <= buf. len ( ) {
174
176
let buf = & buf[ ..pending. len ] ;
177
+
178
+ // We only do this check in debug mode since it's an expensive check.
179
+ #[ cfg( debug_assertions) ]
175
180
if Self :: digest ( buf) == pending. digest {
176
181
return Ok ( buf) ;
177
182
}
183
+
184
+ #[ cfg( not( debug_assertions) ) ]
185
+ return Ok ( buf) ;
178
186
}
179
187
Err ( io:: Error :: new (
180
188
io:: ErrorKind :: Other ,
@@ -189,6 +197,7 @@ impl WriteTracker {
189
197
& Poll :: Pending => {
190
198
if self . pending . is_none ( ) {
191
199
self . pending = Some ( Box :: new ( DigestAndLen {
200
+ #[ cfg( debug_assertions) ]
192
201
digest : Self :: digest ( buf) ,
193
202
len : buf. len ( ) ,
194
203
} ) ) ;
You can’t perform that action at this time.
0 commit comments