@@ -39,21 +39,16 @@ where
3939 R : Read + AsFd + AsRawFd ,
4040 S : Write + AsFd + AsRawFd ,
4141{
42- // If we're on Linux or Android, try to use the splice() system call
43- // for faster writing. If it works, we're done.
44- // todo: bypass broker pipe this if input or output is pipe. We use this mostly for stream.
45- if !crate :: pipes:: splice_unbounded_broker ( src, dest) ? {
46- return Ok ( ( ) ) ;
42+ // try to use the splice() system call
43+ // for faster writing. If it works, we're done
44+ if crate :: pipes:: splice_unbounded_auto ( & src, dest) ? {
45+ std:: io:: copy ( src, dest) ?;
46+ // If the splice() call failed and there has been some data written to
47+ // stdout via while loop above AND there will be second splice() call
48+ // that will succeed, data pushed through splice will be output before
49+ // the data buffered in stdout.lock. Therefore additional explicit flush
50+ // is required here.
51+ dest. flush ( ) ?;
4752 }
48-
49- // If the splice() call failed, fall back on slower writing.
50- std:: io:: copy ( src, dest) ?;
51-
52- // If the splice() call failed and there has been some data written to
53- // stdout via while loop above AND there will be second splice() call
54- // that will succeed, data pushed through splice will be output before
55- // the data buffered in stdout.lock. Therefore additional explicit flush
56- // is required here.
57- dest. flush ( ) ?;
5853 Ok ( ( ) )
5954}
0 commit comments