| 1 | 1 | ▶ | use v5.28; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use feature 'signatures'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | no warnings 'experimental::signatures'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | package Archive::SCS::CityHash 1.12; | ||
| 7 | |||
| 8 | 1 | ▶ | use Exporter 'import'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 1 | ▶ | use XSLoader 0.14; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | XSLoader::load(); | ||
| 12 | |||
| 13 | |||
| 14 | 1 | ▶ | BEGIN { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 15 | 1 | our @EXPORT_OK = qw( | |
| 16 | cityhash64 | ||
| 17 | cityhash64_int | ||
| 18 | cityhash64_hex | ||
| 19 | cityhash64_as_hex | ||
| 20 | cityhash64_as_int | ||
| 21 | ); | ||
| 22 | } | ||
| 23 | |||
| 24 | |||
| 25 | # Input: the original file path as a string | ||
| 26 | # Output: the internal format | ||
| 27 | 0 | ▶ | sub cityhash64 :prototype($) ($path) { |
|
Subroutine
cityhash64: not called CC=1 SCAR=6.9
| |||
| 28 | 0 | sprintf '%016x', cityhash64_($path) | |
| 29 | } | ||
| 30 | |||
| 31 | |||
| 32 | # Input: the hash as integer | ||
| 33 | # Output: the internal format | ||
| 34 | 0 | ▶ | sub cityhash64_int :prototype($) ($hash_int) { |
|
Subroutine
cityhash64_int: not called CC=1 SCAR=6.9
| |||
| 35 | 0 | sprintf '%016x', $hash_int | |
| 36 | } | ||
| 37 | |||
| 38 | |||
| 39 | # Input: the hash as 16-byte hex-encoded string scalar | ||
| 40 | # Output: the internal format | ||
| 41 | 0 | ▶ | sub cityhash64_hex :prototype($) ($hash_hex) { |
|
Subroutine
cityhash64_hex: not called CC=1 SCAR=6.9
| |||
| 42 | 0 | $hash_hex | |
| 43 | } | ||
| 44 | |||
| 45 | |||
| 46 | # Input: the internal format | ||
| 47 | # Output: the hash as 16-byte hex-encoded string scalar (human-readable) | ||
| 48 | 0 | ▶ | sub cityhash64_as_hex :prototype($) ($hash) { |
|
Subroutine
cityhash64_as_hex: not called CC=1 SCAR=6.9
| |||
| 49 | 0 | $hash | |
| 50 | } | ||
| 51 | |||
| 52 | |||
| 53 | # Input: the internal format | ||
| 54 | # Output: the hash as integer | ||
| 55 | 0 | ▶ | sub cityhash64_as_int :prototype($) ($hash) { |
|
Subroutine
cityhash64_as_int: not called CC=1 SCAR=0.2
| |||
| 56 | # No need to worry about 32-bit systems, this dist doesn't build on those anyway | ||
| 57 | 1 | ▶ | no warnings 'portable'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 58 | 0 | hex $hash | |
| 59 | } | ||
| 60 | |||
| 61 | |||
| 62 | # The "internal format" of the hash is a 16-byte hex PV in network byte order. | ||
| 63 | |||
| 64 | 1; | ||