Skip to content

Commit 9bec7dd

Browse files
authored
Merge pull request #112 from EagleAglow/main
Version 2.2
2 parents 8be9469 + f650715 commit 9bec7dd

3 files changed

Lines changed: 10 additions & 10 deletions

File tree

entries/bfire/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,4 @@ Finally, the TStringList is sorted and used to output sorted data.
5656
- Version 1.1: modified rounding to new baseline.
5757
- Version 2.0: use hashing, sort later.
5858
- Version 2.1: minor speed tweaks.
59+
- Version 2.2: try hash functions modification.

entries/bfire/src/ProcessByHashUnit.pas

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,15 +191,17 @@ function BytesToIndexHash;
191191
// convert entry_chars to hash
192192
// use Prime: Integer = 75013;
193193
var
194-
G: Integer;
194+
G: Cardinal;
195195
i: Integer;
196-
Hash: Integer;
196+
Hash: Cardinal;
197197
begin
198198
Hash := 0;
199-
for i := 0 to entry_name_array_length - 1 do
199+
// for i := 0 to entry_name_array_length - 1 do
200+
for i := entry_name_array_length - 1 downto 0 do
200201
begin
201202
Hash := (Hash shl 4) + entry_name_array[i];
202203
G := Hash and $F0000000;
204+
// G := Hash and $F000000;
203205
if (G <> 0) then
204206
Hash := (Hash xor (G shr 24)) xor G;
205207
end;
@@ -310,9 +312,9 @@ procedure HashAndSave;
310312
end
311313
else // collision, try next spot in HashMap array
312314
begin
313-
Inc(entry_hash);
314-
if entry_hash >= Prime then
315-
entry_hash := 0; // wrap around
315+
entry_hash := entry_hash + 19;
316+
if entry_hash >= Prime then // wrap around
317+
entry_hash := entry_hash - Prime;
316318
end;
317319
end;
318320
end; // of: while True do
@@ -321,13 +323,11 @@ procedure HashAndSave;
321323

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

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

330-
iFileHandle: Integer;
331331
iBytesRead: Integer;
332332
Buffer: PByte;
333333

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

343343
// Load the data
344344
PlaceCount := 0;
345-
PlaceIndex := 0;
346345
InitializeThings;
347346

348347
if FileExists(inFile) then

entries/bfire/src/version.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
const
2-
cVersion = '2.1';
2+
cVersion = '2.2';

0 commit comments

Comments
 (0)