From ab5584f4213d21cce50c631872480e2a74516a4f Mon Sep 17 00:00:00 2001 From: Orkuncakilkaya Date: Fri, 25 Sep 2026 08:10:46 +0300 Subject: [PATCH] refactor(ludic.lab): the PNG writer's CRC constants are long literals again Co-Authored-By: Claude Opus 5.5 --- packages/ludic.lab/png.ludic | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/packages/ludic.lab/png.ludic b/packages/ludic.lab/png.ludic index 4c7e8dc2..2e4c9534 100644 --- a/packages/ludic.lab/png.ludic +++ b/packages/ludic.lab/png.ludic @@ -3,11 +3,10 @@ # on every row, in deflate's stored blocks, with its CRCs and its Adler-32. var lp_table: []long = null -function lp_u32(hi: int, lo: int) -> long { return long(hi) * long(65536) + long(lo) } function lp_table_init() -> void { if lp_table != null { return } lp_table = new []long - let poly = lp_u32(60856, 33568) # 0xEDB88320 + let poly: long = 3988292384 # 0xEDB88320: eight hex digits would be a 32-bit pattern for n in 0 .. 256 { var c = long(n) for k in 0 .. 8 { @@ -19,7 +18,7 @@ function lp_table_init() -> void { # CRC-32 of out[from .. from + n) function lp_crc(out: []byte, from: int, n: int) -> long { lp_table_init() - let mask = lp_u32(65535, 65535) + let mask: long = 4294967295 var c = mask for i in from .. from + n { let k = int((c ^ long(out[i])) & long(255))