From 20050c68ce42f08f801bd01e03e50ff2bf4ac4c9 Mon Sep 17 00:00:00 2001 From: Mateo Guynn Date: Sat, 23 Jul 2022 15:40:46 -0700 Subject: [PATCH] Use static tables Using `static` instead of `const` reduces the size of output binaries, .rlib, and .rmeta. --- scripts/unicode.py | 2 +- src/tables.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/unicode.py b/scripts/unicode.py index 5b49967..2efb0b6 100755 --- a/scripts/unicode.py +++ b/scripts/unicode.py @@ -440,7 +440,7 @@ pub mod charwidth { module.write( f""" /// Autogenerated. {subtable_count} sub-table(s). Consult [`lookup_width`] for layout info. - const TABLES_{i}: [u8; {len(byte_array)}] = [""" + static TABLES_{i}: [u8; {len(byte_array)}] = [""" ) for (j, byte) in enumerate(byte_array): # Add line breaks for every 15th entry (chosen to match what rustfmt does) diff --git a/src/tables.rs b/src/tables.rs index 2ec2703..699c512 100644 --- a/src/tables.rs +++ b/src/tables.rs @@ -86,7 +86,7 @@ pub mod charwidth { } /// Autogenerated. 1 sub-table(s). Consult [`lookup_width`] for layout info. - const TABLES_0: [u8; 256] = [ + static TABLES_0: [u8; 256] = [ 0x00, 0x01, 0x02, 0x03, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0F, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x03, 0x0F, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, 0x09, @@ -108,7 +108,7 @@ pub mod charwidth { ]; /// Autogenerated. 19 sub-table(s). Consult [`lookup_width`] for layout info. - const TABLES_1: [u8; 2432] = [ + static TABLES_1: [u8; 2432] = [ 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x06, 0x08, 0x06, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x06, 0x06, 0x06, 0x11, 0x12, 0x13, 0x14, 0x06, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x22, 0x24, 0x25, @@ -275,7 +275,7 @@ pub mod charwidth { ]; /// Autogenerated. 240 sub-table(s). Consult [`lookup_width`] for layout info. - const TABLES_2: [u8; 3840] = [ + static TABLES_2: [u8; 3840] = [ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5D, 0xD7, 0x77, 0x75, 0xFF,