File tree Expand file tree Collapse file tree 2 files changed +10
-0
lines changed Expand file tree Collapse file tree 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" ] || [
1313 rustup default $TRAVIS_RUST_VERSION
1414 # make sure that explicitly providing the default target works
1515 cargo test --target x86_64-unknown-linux-gnu
16+ cargo test --release
1617 cargo test --features spin_threading
1718 cargo test --features rust_threading
1819 cargo test --features custom_time,custom_gmtime_r
Original file line number Diff line number Diff line change @@ -147,6 +147,7 @@ struct WriteTracker {
147147}
148148
149149struct DigestAndLen {
150+ #[ cfg( debug_assertions) ]
150151 digest : [ u8 ; 20 ] , // SHA-1
151152 len : usize ,
152153}
@@ -158,6 +159,7 @@ impl WriteTracker {
158159 }
159160 }
160161
162+ #[ cfg( debug_assertions) ]
161163 fn digest ( buf : & [ u8 ] ) -> [ u8 ; 20 ] {
162164 use crate :: hash:: { Md , Type } ;
163165 let mut out = [ 0u8 ; 20 ] ;
@@ -172,9 +174,15 @@ impl WriteTracker {
172174 Some ( pending) => {
173175 if pending. len <= buf. len ( ) {
174176 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) ]
175180 if Self :: digest ( buf) == pending. digest {
176181 return Ok ( buf) ;
177182 }
183+
184+ #[ cfg( not( debug_assertions) ) ]
185+ return Ok ( buf) ;
178186 }
179187 Err ( io:: Error :: new (
180188 io:: ErrorKind :: Other ,
@@ -189,6 +197,7 @@ impl WriteTracker {
189197 & Poll :: Pending => {
190198 if self . pending . is_none ( ) {
191199 self . pending = Some ( Box :: new ( DigestAndLen {
200+ #[ cfg( debug_assertions) ]
192201 digest : Self :: digest ( buf) ,
193202 len : buf. len ( ) ,
194203 } ) ) ;
You can’t perform that action at this time.
0 commit comments