inline: store link cowstrs in vec

try to reduce size of Event by placing the cowstr in a shared vec, and
just keeping an index in the event itself

seems to have a significant performance benefit on benchmarks
This commit is contained in:
Noah Hellman 2023-03-23 19:23:16 +01:00
parent a846477cea
commit 2bcc6122ca
2 changed files with 75 additions and 64 deletions

View file

@ -830,14 +830,17 @@ impl<'s> Parser<'s> {
inline::Container::Emphasis => Container::Emphasis,
inline::Container::Strong => Container::Strong,
inline::Container::Mark => Container::Mark,
inline::Container::InlineLink(url) => {
Container::Link(url, LinkType::Span(SpanLinkType::Inline))
}
inline::Container::InlineImage(url) => {
Container::Image(url, SpanLinkType::Inline)
}
inline::Container::ReferenceLink(ref tag)
| inline::Container::ReferenceImage(ref tag) => {
inline::Container::InlineLink(url) => Container::Link(
self.inline_parser.store_cowstrs[url as usize].clone(),
LinkType::Span(SpanLinkType::Inline),
),
inline::Container::InlineImage(url) => Container::Image(
self.inline_parser.store_cowstrs[url as usize].clone(),
SpanLinkType::Inline,
),
inline::Container::ReferenceLink(tag)
| inline::Container::ReferenceImage(tag) => {
let tag = &self.inline_parser.store_cowstrs[tag as usize];
let link_def = self
.pre_pass
.link_definitions