tvl-depot/third_party/lisp/mime4cl
sterni 3d2e55ad53 refactor(mime4cl): replace *-input-adapter-stream with flexi-streams
The input adapter streams were input streams yielding either binary or
character data that could be constructed from a variable data source.
The stream would take care not to destroy the underlying data
source (i.e. not close it if it was a stream), so similar to with
FILE-PORTIONs, but simpler.

Unfortunately, the implementation was quite inefficient: They are
ultimately defined in terms of a function that retrieves the next
character in the source. This only allows for an implementation of
READ-CHAR (and READ-BYTE). Thanks to cl/8559, READ-SEQUENCE can be used
on e.g. FILE-PORTION, but this was still negated by a input adapter
based on one—then, READ-SEQUENCE would need to fall back on READ-CHAR or
READ-BYTE again.

Luckily, we can replace BINARY-INPUT-ADAPTER-STREAM and
CHARACTER-INPUT-ADAPTER-STREAM with a much simpler abstraction: Instead
of extra stream classes, we have a function, MAKE-INPUT-ADAPTER, which
returns an appropriate instance of FLEXI-STREAM based on a given source.
This way, the need for a distinction between binary and character input
adapter is eliminated, since FLEXI-STREAMS supports both binary and
character reads (external format is not yet handled, though).
Consequently, the :binary keyword argument to MIME-BODY-STREAM can be
dropped.

flexi-streams provides stream classes for everything except a stream
that doesn't close the underlying one. Since we have already implemented
this in POSITIONED-FLEXI-INPUT-STREAM, we can split this functionality
into a new superclass ADAPTER-FLEXI-INPUT-STREAM.

This change also allows addressing the performance regression
encountered in cl/8559: It seems that flexi-streams performs worse when
we are reading byte by byte or char by char. (After this change mblog is
still two times slower than on r/6150.) By eliminating the adapter
streams, we can start utilizing READ-SEQUENCE via decoding code that
supports it (i.e. qbase64) and bring performance on par with r/6150
again. Surely there are also ways to gain back even more performance
which has to be determined using profiling. Buffering more aggressively
seems like a sure bet, though.

Switching to flexi-streams still seems like a no-brainer, as it allows
us to drop a lot of code that was quite hacky (e.g. DELIMITED-INPUT-
STREAM) and implements en/decoding handling we did not support before,
but would need for improved correctness.

Change-Id: Ie2d1f4e42b47512a5660a1ccc0deeec2bff9788d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8581
Autosubmit: sterni <sternenseemann@systemli.org>
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
2023-05-18 16:14:38 +00:00
..
test refactor(3p/lisp/mime4cl/test): create one test case per sample file 2023-05-16 16:25:11 +00:00
.skip-subtree feat(3p/lisp/mime4cl): build using buildLisp 2021-09-01 22:57:17 +00:00
address.lisp chore(3p/lisp/mime4cl): remove CMUCL specific code 2022-01-26 17:43:54 +00:00
default.nix fix(3p/lisp/mime4cl/tests): fix sample discovery in nix build 2023-05-09 16:44:55 +00:00
endec.lisp refactor(3p/lisp/mime4cl): replace babel with flexi-streams 2023-03-30 16:11:54 +00:00
ex-sclf.lisp chore: remove sclf from the tree 2022-07-05 15:01:17 +00:00
mime.lisp refactor(mime4cl): replace *-input-adapter-stream with flexi-streams 2023-05-18 16:14:38 +00:00
mime4cl-tests.asd chore(3p/lisp/mime4cl): remove CMUCL specific code 2022-01-26 17:43:54 +00:00
mime4cl.asd refactor(3p/lisp/mime4cl): use trivial-gray-streams 2022-01-26 17:43:54 +00:00
OWNERS chore(gerrit): migrate OWNERS files to code-owners style 2022-09-19 11:13:28 +00:00
package.lisp refactor(3p/lisp/mime4cl): replace babel with flexi-streams 2023-03-30 16:11:54 +00:00
README feat(3p/lisp/mime4cl): build using buildLisp 2021-09-01 22:57:17 +00:00
streams.lisp refactor(mime4cl): replace *-input-adapter-stream with flexi-streams 2023-05-18 16:14:38 +00:00

MIME4CL is a Common Lisp library for dealing with MIME messages.
It has originally been written by Walter C. Pelissero and vendored
into depot as upstream has become inactive and provides no repo
of any kind. Upstream and depot version may diverge.

Upstream Website: http://wcp.sdf-eu.org/software/#mime4cl
Vendored Tarball: http://wcp.sdf-eu.org/software/mime4cl-20150207T211851.tbz