Skip to content

Instantly share code, notes, and snippets.

@MasterDuke17
Created March 20, 2020 00:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MasterDuke17/89b1281e49a38b3ff99ec92d6856f927 to your computer and use it in GitHub Desktop.
Save MasterDuke17/89b1281e49a38b3ff99ec92d6856f927 to your computer and use it in GitHub Desktop.
diff --git a/lib/String/CRC32.pm b/lib/String/CRC32.pm
index cd31891..78b73a6 100644
--- a/lib/String/CRC32.pm
+++ b/lib/String/CRC32.pm
@@ -5,7 +5,7 @@ use v6;
unit class String::CRC32:auth<cosimo>:ver<0.05>;
-my @CRC_TABLE =
+my int @CRC_TABLE =
0x0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3,
0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91,
0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7,
@@ -41,10 +41,9 @@ my @CRC_TABLE =
our proto sub crc32($) {*}
multi sub crc32 (Blob $b) {
- my $crcinit = 0;
- my $crc = $crcinit +^ 0xFFFFFFFF;
+ my int $crc = 0xFFFFFFFF;
- for $b.list -> $char {
+ for $b.list -> int $char {
$crc = (($crc +> 8) +& 0x00FFFFFF) +^ @CRC_TABLE[ ($crc +^ $char) +& 0xFF ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment