Skip to content

Commit c05cbce

Browse files
committed
Change buffer minimum size to match optimal read size. Also change
non-sourced buffer read size to be small (useful for crude appender)
1 parent 171687a commit c05cbce

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

source/iopipe/bufpipe.d

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,15 +552,16 @@ private struct BufferedInputSource(BufferManager, Source, size_t optimalReadSize
552552
* dev = The input stream to use. If not specified, then a NullDev source is assumed.
553553
*
554554
* Returns: An iopipe that uses the given buffer to read data from the given device source.
555+
* The version which takes no parameter uses a NullDev as a source.
555556
*/
556557
auto bufd(T=ubyte, Allocator = GCNoPointerAllocator, size_t optimalReadSize = 8 * 1024 / T.sizeof, Source)(Source dev)
557558
if(hasMember!(Source, "read") && is(typeof(dev.read(T[].init)) == size_t))
558559
{
559-
return BufferedInputSource!(AllocatedBuffer!(T, Allocator), Source, optimalReadSize)(dev);
560+
return BufferedInputSource!(AllocatedBuffer!(T, Allocator, optimalReadSize), Source, optimalReadSize)(dev);
560561
}
561562

562563
/// ditto
563-
auto bufd(T=ubyte, Allocator = GCNoPointerAllocator, size_t optimalReadSize = 8 * 1024 / T.sizeof)()
564+
auto bufd(T=ubyte, Allocator = GCNoPointerAllocator, size_t optimalReadSize = (T.sizeof > 4 ? 8 : 32 / T.sizeof))()
564565
{
565566
import iopipe.stream: nullDev;
566567
return nullDev.bufd!(T, Allocator, optimalReadSize)();

0 commit comments

Comments
 (0)