diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2023-07-05 15:02:04 +0200 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2023-07-05 15:02:04 +0200 |
commit | bc7214228a10b613057a8c319534d2fd4560175f (patch) | |
tree | 1918e920192d43b2cef60d89921b43f5f52ddf36 /openpgp/src/parse.rs | |
parent | fe58f69466d947f51d7bd43e474f5fec2e8e7cc9 (diff) |
openpgp: Don't put the packet body in the map unless we're buffering
- Previously, Sequoia would buffer packet bodies when mapping is
enabled in the parser, even if the packet parser is not
configured to buffer the bodies. This adds considerable
overhead.
- With this change, Sequoia no longer includes the packet bodies in
the maps unless the parser is configured to buffer any unread
content.
- This makes parsing packets faster if you don't rely on the packet
body in the map, but changes the default behavior. If you need
the old behavior, please do adjust your code to buffer unread
content.
Diffstat (limited to 'openpgp/src/parse.rs')
-rw-r--r-- | openpgp/src/parse.rs | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/openpgp/src/parse.rs b/openpgp/src/parse.rs index f5b3bff8..b6289219 100644 --- a/openpgp/src/parse.rs +++ b/openpgp/src/parse.rs @@ -530,7 +530,11 @@ impl<'a> PacketHeaderParser<'a> { if self.state.settings.map { // Steal the body for the map. self.reader.rewind(); - let body = self.reader.steal_eof()?; + let body = if self.state.settings.buffer_unread_content { + self.reader.steal_eof()? + } else { + self.reader.steal(total_out)? + }; if body.len() > total_out { self.field("body", body.len() - total_out); } |