From e79c9d88aa5ed1f98d924d04ab604c3983bda7b3 Mon Sep 17 00:00:00 2001 From: Jack Lloyd Date: Tue, 27 Aug 2024 13:31:02 -0400 Subject: [PATCH] Use one weird trick to reduce the size of your crate by 100+ MB No, seriously. For reasons I have not been able to pin down, it seems like include_str is treated differently from include_bytes. This change reduces the sizes of the binaries libwycheproof.rlib and libwycheproof.rmeta from 150M/69M to 88M/7.2M --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 994fe27..e18d43f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -162,7 +162,7 @@ macro_rules! define_test_set_names { pub fn json_data(&self) -> &'static str { match self { $( - Self::$enum_name => include_str!(concat!("data/", $test_name, "_test.json")), + Self::$enum_name => std::str::from_utf8(include_bytes!(concat!("data/", $test_name, "_test.json"))).expect("Invalid UTF8"), )* } }