summary history branches tags files
commit:e318674619aabdaa28951dc937bfd202787b2aa8
author:Trevor Bentley
committer:Trevor Bentley
date:Sun Jan 20 22:55:41 2019 +0100
parents:818de112b25b1a4772bc9226e54e296171bced05
Shrink test loops
diff --git a/benches/basic.rs b/benches/basic.rs
line changes: +15/-26
index a9c625c..e66fb52
--- a/benches/basic.rs
+++ b/benches/basic.rs
@@ -106,36 +106,25 @@ fn bench_test(b: &mut Bencher) {
             _ => panic!("Send failed"),
         }
     }
-    loop {
-        match crypto_flush(&mut client_conn, &mut client_stream) {
-            Ok(w) => {
-                if w == 0 {
-                    break;
-                }
-                println!("flushed: {}", w);
-            },
-            _ => panic!("Flush failed"),
+
+    while let Ok(w) = crypto_flush(&mut client_conn, &mut client_stream) {
+        if w == 0 {
+            break;
         }
     }
 
+    // Unwrap stream until it succeeds to force it to flush.
     let mut client_stream: Option<std::io::BufWriter<_>> = Some(client_stream);
-    loop {
-        client_stream = match client_stream {
-            None => break,
-            Some(s) => match s.into_inner() {
-                Ok(_) => None,
-                Err(e) => {
-                    match e.error().kind() {
-                        std::io::ErrorKind::WouldBlock => {
-                            Some(e.into_inner())
-                        },
-                        _ => panic!("error: {:?}", e.error()),
-                    }
-                },
-            }
-        };
+    while let Some(s) = client_stream {
+        client_stream = match s.into_inner() {
+            Err(e) => {
+                match e.error().kind() {
+                    std::io::ErrorKind::WouldBlock => Some(e.into_inner()),
+                    _ => None,
+                }
+            },
+            _ => None,
+        }
     }
-    println!("flushed");
-    //drop(client_stream); // flush the buffer
     let _ = server_thread.join();
 }