@@ -326,13 +326,9 @@ class InputMemoryStream final : public InputStream {
326
326
// All data written to this stream can be read from it. Reading and writing is done
327
327
// using different offsets, meaning that it is not necessary to seek to the start
328
328
// before reading; this behaviour differs from BufferStream.
329
- //
330
- // The stream keeps a history of 64KiB which means that seeking backwards is well
331
- // defined. Data past that point will be discarded.
332
329
class DuplexMemoryStream final : public DuplexStream {
333
330
public:
334
331
static constexpr size_t chunk_size = 4 * 1024 ;
335
- static constexpr size_t history_size = 64 * 1024 ;
336
332
337
333
bool eof () const override { return m_write_offset == m_read_offset; }
338
334
@@ -411,22 +407,6 @@ class DuplexMemoryStream final : public DuplexStream {
411
407
return nread;
412
408
}
413
409
414
- size_t read (Bytes bytes, size_t offset)
415
- {
416
- const auto backup = this ->roffset ();
417
-
418
- bool do_discard_chunks = false ;
419
- exchange (m_do_discard_chunks, do_discard_chunks);
420
-
421
- rseek (offset);
422
- const auto count = read (bytes);
423
- rseek (backup);
424
-
425
- exchange (m_do_discard_chunks, do_discard_chunks);
426
-
427
- return count;
428
- }
429
-
430
410
bool read_or_error (Bytes bytes) override
431
411
{
432
412
if (m_write_offset - m_read_offset < bytes.size ()) {
@@ -461,22 +441,12 @@ class DuplexMemoryStream final : public DuplexStream {
461
441
size_t roffset () const { return m_read_offset; }
462
442
size_t woffset () const { return m_write_offset; }
463
443
464
- void rseek (size_t offset)
465
- {
466
- ASSERT (offset >= m_base_offset);
467
- ASSERT (offset <= m_write_offset);
468
- m_read_offset = offset;
469
- }
470
-
471
444
size_t remaining () const { return m_write_offset - m_read_offset; }
472
445
473
446
private:
474
447
void try_discard_chunks ()
475
448
{
476
- if (!m_do_discard_chunks)
477
- return ;
478
-
479
- while (m_read_offset - m_base_offset >= history_size + chunk_size) {
449
+ while (m_read_offset - m_base_offset >= chunk_size) {
480
450
m_chunks.take_first ();
481
451
m_base_offset += chunk_size;
482
452
}
@@ -486,7 +456,6 @@ class DuplexMemoryStream final : public DuplexStream {
486
456
size_t m_write_offset { 0 };
487
457
size_t m_read_offset { 0 };
488
458
size_t m_base_offset { 0 };
489
- bool m_do_discard_chunks { false };
490
459
};
491
460
492
461
}
0 commit comments