Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions entries/bfire/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ Finally, the TStringList is sorted and used to output sorted data.
- Version 1.1: modified rounding to new baseline.
- Version 2.0: use hashing, sort later.
- Version 2.1: minor speed tweaks.
- Version 2.2: try hash functions modification.
17 changes: 8 additions & 9 deletions entries/bfire/src/ProcessByHashUnit.pas
Original file line number Diff line number Diff line change
Expand Up @@ -191,15 +191,17 @@ function BytesToIndexHash;
// convert entry_chars to hash
// use Prime: Integer = 75013;
var
G: Integer;
G: Cardinal;
i: Integer;
Hash: Integer;
Hash: Cardinal;
begin
Hash := 0;
for i := 0 to entry_name_array_length - 1 do
// for i := 0 to entry_name_array_length - 1 do
for i := entry_name_array_length - 1 downto 0 do
begin
Hash := (Hash shl 4) + entry_name_array[i];
G := Hash and $F0000000;
// G := Hash and $F000000;
if (G <> 0) then
Hash := (Hash xor (G shr 24)) xor G;
end;
Expand Down Expand Up @@ -310,9 +312,9 @@ procedure HashAndSave;
end
else // collision, try next spot in HashMap array
begin
Inc(entry_hash);
if entry_hash >= Prime then
entry_hash := 0; // wrap around
entry_hash := entry_hash + 19;
if entry_hash >= Prime then // wrap around
entry_hash := entry_hash - Prime;
end;
end;
end; // of: while True do
Expand All @@ -321,13 +323,11 @@ procedure HashAndSave;

procedure FileToArrays(inFile: String; UseStdOut: Boolean); inline;
var
PlaceIndex: Integer; // location in index array
i: Integer; // used for temporary purposes

LF: Boolean; // True after finding #10
SC: Boolean; // True after finding semi-colon

iFileHandle: Integer;
iBytesRead: Integer;
Buffer: PByte;

Expand All @@ -342,7 +342,6 @@ procedure FileToArrays(inFile: String; UseStdOut: Boolean); inline;

// Load the data
PlaceCount := 0;
PlaceIndex := 0;
InitializeThings;

if FileExists(inFile) then
Expand Down
2 changes: 1 addition & 1 deletion entries/bfire/src/version.inc
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
const
cVersion = '2.1';
cVersion = '2.2';