From 10048b0d31d0db923ae39c6bbd67139ed6252f6f Mon Sep 17 00:00:00 2001 From: Sam Atman Date: Wed, 30 Apr 2025 20:30:39 -0400 Subject: Allocation Failure Tests These turned up an excessive amount of allocations in CanonData and CompatData, which have been reduced to two through the somewhat squirrely use of 'magic numbers'. There are now allocation tests for every allocated structure in the library, and they run to completion in a reasonable amount of time. So, that's nice. --- src/magic_numbers.zig | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/magic_numbers.zig (limited to 'src/magic_numbers.zig') diff --git a/src/magic_numbers.zig b/src/magic_numbers.zig new file mode 100644 index 0000000..203bdfd --- /dev/null +++ b/src/magic_numbers.zig @@ -0,0 +1,15 @@ +//! 'Magic' numbers for codegen sizing +//! +//! These need to be updated for each Unicode version. + +// Whether to print the magic numbers +pub const print = false; + +// Don't want to crash while printing magic... +const fudge = if (print) 1000 else 0; + +// Number of codepoints in CanonData.zig +pub const canon_size: usize = 3127 + fudge; + +// Number of codepoitns in CompatData.zig +pub const compat_size: usize = 5612 + fudge; -- cgit v1.2.3