Skip to content

Commit

Permalink
makecasefoldhashtable.pl: Report size of case-folding hashtable.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Mar 25, 2024
1 parent e63e3d6 commit 101a91c
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions extras/makecasefoldhashtable.pl
Expand Up @@ -8,6 +8,8 @@
my $HASHBUCKETS2_16 = 16;
my $HASHBUCKETS3_16 = 4;

my $mem_used = 0;

print <<__EOF__;
/*
* This file is part of PhysicsFS (https://icculus.org/physfs/)
Expand Down Expand Up @@ -143,18 +145,22 @@
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS1_32-1));
#print("// hexxed '$hexxed' hashed1 '$hashed'\n");
$foldPairs1_32[$hashed] .= " { 0x$code, 0x$map1 },\n";
$mem_used += 8;
} elsif (not defined($map2)) {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS1_16-1));
#print("// hexxed '$hexxed' hashed1 '$hashed'\n");
$foldPairs1_16[$hashed] .= " { 0x$code, 0x$map1 },\n";
$mem_used += 4;
} elsif (not defined($map3)) {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS2_16-1));
#print("// hexxed '$hexxed' hashed2 '$hashed'\n");
$foldPairs2_16[$hashed] .= " { 0x$code, 0x$map1, 0x$map2 },\n";
$mem_used += 6;
} else {
my $hashed = (($hexxed ^ ($hexxed >> 8)) & ($HASHBUCKETS3_16-1));
#print("// hexxed '$hexxed' hashed3 '$hashed'\n");
$foldPairs3_16[$hashed] .= " { 0x$code, 0x$map1, 0x$map2, 0x$map3 },\n";
$mem_used += 8;
}
}
}
Expand Down Expand Up @@ -212,6 +218,7 @@
my $sym = "case_fold1_16_${num}";
print(" { $sym, __PHYSFS_ARRAYLEN($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");

Expand All @@ -228,6 +235,7 @@
my $sym = "case_fold1_32_${num}";
print(" { $sym, __PHYSFS_ARRAYLEN($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");

Expand All @@ -244,6 +252,7 @@
my $sym = "case_fold2_16_${num}";
print(" { $sym, __PHYSFS_ARRAYLEN($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");

Expand All @@ -259,6 +268,7 @@
my $sym = "case_fold3_16_${num}";
print(" { $sym, __PHYSFS_ARRAYLEN($sym) },\n");
}
$mem_used += 12;
}
print("};\n\n");

Expand All @@ -270,6 +280,8 @@
__EOF__

print STDERR "Memory required for case-folding hashtable: $mem_used bytes\n";

exit 0;

# end of makecashfoldhashtable.pl ...
Expand Down

0 comments on commit 101a91c

Please sign in to comment.