Skip to content

Commit

Permalink
Ускорен алгоритм хеширования имён (#310, #319)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mazdaywik committed Nov 23, 2020
1 parent 470e9ff commit 68c6235
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/compiler/TreeUtils.ref
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
$INCLUDE "LibraryEx";

*$FROM Hash
$EXTERN HashLittle2-Chars;


/**
<ExtractVariables e.Sentences> == e.Variables
Expand Down Expand Up @@ -146,11 +149,22 @@ $ENTRY AddSuffix {
*/
$ENTRY HashName {
e.Name s.Buckets
= <Ord e.Name>
= e.Name
: {
e.Base SUF e.Suffix = e.Base 997 e.Suffix;
e.Base SUF e.Suffix = e.Base <HashName-Suffix e.Suffix>;
e.Name^ = e.Name;
}
: e.NameAsNumbers
= <Mod (e.NameAsNumbers) s.Buckets>
: e.NameAsStr
* base64 -w 8 /dev/urandom | \
* awk '/^[0-9a-fA-F]*$/ { print strtonum("0x" $1) }' | \
* head -2 | clip.exe
= <HashLittle2-Chars 3161351997 4067679699 e.NameAsStr> : s.Hash1 s.Hash2
= <Mod s.Hash1 s.Buckets>
}

HashName-Suffix {
s.SufChar s.SufNo e.Suffix
= s.SufChar <Symb s.SufNo> <HashName-Suffix e.Suffix>;

/* empty */ = /* empty */;
}

0 comments on commit 68c6235

Please sign in to comment.