-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Replace readUntilDelimiter* with streamUntilDelimiter #15528
Copy link
Copy link
Closed
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Metadata
Metadata
Assignees
Labels
enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Type
Fields
Give feedbackNo fields configured for issues without a type.
readUntilDelimiterArrayListis great if you want to read delimited data into a dynamically allocated buffer. However, sometimes you may want to read delimited data into aBoundedArray(for allocation-free code, or when you know the max size will be small), or send it directly to a writer (eg. for converting a newline-separated stream into a NUL-separated stream or similar).These usecases are possible today, but they're a bit awkward and don't work as well as they should:
I propose to replace
readUntilDelimiter,readUntilDelimiterOrEof, andreadUntilDelimiterArrayListwith a new function,streamUntilDelimiter(name up for discussion, I don't hugely like this one but can't think of anything better):I would recommend removing
readUntilDelimiterAllocandreadUntilDelimiterOrEofAlloc, since they're already pretty much superseded byreadUntilDelimiterArrayListwhich is never slower, often faster, and rarely significantly harder to use.