Commit graph

11 commits

Author SHA1 Message Date
Ben Wiederhake 041f5e931d AK: Use AK_MAKE_DEFAULT_MOVABLE to avoid mistakes in default impls 2023-06-18 08:47:51 +01:00
Tim Schumacher 221b91ff61 AK: Add CircularBuffer::find_copy_in_seekback()
This is useful for compressors, which quite frequently need to find a
matching span of data within the seekback.
2023-05-17 09:08:53 +02:00
Lucas CHOLLET 48b000a36c AK: Add CircularBuffer::flush_to_stream
In a similar fashion to what have been done with `fill_from_stream`,
this new method allows to write CircularBuffer's data to a Stream
without additional copies.
2023-05-09 11:18:46 +02:00
Tim Schumacher 767fb01a8c AK: Report copied bytes when seekback copying from CircularBuffer
Otherwise, we have no way of determining whether our copy was truncated
by accident.
2023-04-05 07:30:38 -04:00
Timothy Flynn 8b56d82865 AK+LibCompress: Remove the Deflate back-reference intermediate buffer
Instead of reading bytes from the output stream into a buffer, just to
immediately write them back out, we can skip the middle-man and copy the
bytes directly into the output buffer.
2023-03-31 06:56:11 +02:00
Timothy Flynn 5c38b14045 AK: Remove arbitrary 1 KB limit when filling a BufferedStream's buffer
When reading, we currently only fill a BufferedStream's buffer when it
is empty, and only with 1 KB of data. This means that while the buffer
defaults to a size of 16 KB, at least 15 KB is always unused.
2023-03-30 08:47:22 +02:00
Tim Schumacher 52d9fc92f1 AK: Expose the seekback limit of CircularBuffer 2023-03-21 10:25:13 +01:00
Lucas CHOLLET 9a7accddb7 AK: Add an optional starting offset to CircularBuffer::offset_of
This parameter allows to start searching after an offset. For example,
to resume a search.

It is unfortunately a breaking change in API so this patch also modifies
one user and one test.
2023-01-14 16:20:30 -07:00
Lucas CHOLLET 34922c0cc0 AK: Default move operators for CircularBuffer
The previously defined operator was swap-based. With the defaulted
implementation, both integers are now copied, but it doesn't matter as
only the `ByteBuffer` allocates memory (i.e. non-null integers values
won't affect the destruction).
2023-01-14 16:15:31 -07:00
Tim Schumacher d717a08003 AK: Add CircularBuffer::read_with_seekback 2023-01-13 17:34:45 -07:00
Lucas CHOLLET f12e81b74a AK: Add CircularBuffer
The class is very similar to `CircularDuplexStream` in its behavior.
Main differences are that `CircularBuffer`:
 - does not inherit from `AK::Stream`
 - uses `ErrorOr` for its API
 - is heap allocated (and OOM-Safe)

 This patch also add some tests.
2022-12-31 04:44:17 -07:00