From 9db6e533cd8a1d925a7daad92e1b99e6f98ac773 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Sat, 26 Nov 2022 15:34:02 +0100 Subject: [PATCH] Make content a bit more compact --- Cargo.lock | 7 +++++++ Cargo.toml | 1 + src/model/content.rs | 39 +++++++++++++++++++++++++++------------ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 23e40dfeb..a043bea2e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1052,6 +1052,12 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "thin-vec" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ceb05e71730d396f960f8f3901cdb41be2d339b303e9d7d3a07c5ff0536e671b" + [[package]] name = "thiserror" version = "1.0.37" @@ -1127,6 +1133,7 @@ dependencies = [ "subsetter", "svg2pdf", "syntect", + "thin-vec", "tiny-skia", "ttf-parser 0.17.1", "typst-macros", diff --git a/Cargo.toml b/Cargo.toml index fba8f5b3a..d0b7a0269 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,6 +32,7 @@ siphasher = "0.3" subsetter = "0.1" svg2pdf = "0.4" syntect = { version = "5", default-features = false, features = ["default-syntaxes", "regex-fancy"] } +thin-vec = "0.2" tiny-skia = "0.6.2" ttf-parser = "0.17" unicode-segmentation = "1" diff --git a/src/model/content.rs b/src/model/content.rs index a71617987..2f7e7671b 100644 --- a/src/model/content.rs +++ b/src/model/content.rs @@ -7,6 +7,7 @@ use std::sync::Arc; use comemo::Tracked; use siphasher::sip128::{Hasher128, SipHasher}; +use thin_vec::ThinVec; use typst_macros::node; use super::{capability, Args, Guard, Key, Property, Recipe, Style, StyleMap, Value, Vm}; @@ -19,9 +20,15 @@ use crate::World; #[derive(Clone, Hash)] pub struct Content { obj: Arc, - guards: Vec, span: Option, - label: Option