summaryrefslogtreecommitdiffstats
path: root/src/search.php
diff options
context:
space:
mode:
authorDimitri van Heesch <dimitri@stack.nl>2005-05-08 21:32:24 (GMT)
committerDimitri van Heesch <dimitri@stack.nl>2005-05-08 21:32:24 (GMT)
commit5bd970b12ec39636593453d12e5b64bd935bbf38 (patch)
treec4bbe961812e7008b9e85fd820596290c043c0f6 /src/search.php
parent4a8c2f5c896a1883a0611d972952a68498002ae5 (diff)
downloadDoxygen-5bd970b12ec39636593453d12e5b64bd935bbf38.zip
Doxygen-5bd970b12ec39636593453d12e5b64bd935bbf38.tar.gz
Doxygen-5bd970b12ec39636593453d12e5b64bd935bbf38.tar.bz2
Release-1.4.2-20050508
Diffstat (limited to 'src/search.php')
-rw-r--r--src/search.php32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/search.php b/src/search.php
index ee8802a..b3ac0e6 100644
--- a/src/search.php
+++ b/src/search.php
@@ -21,24 +21,26 @@ function readHeader($file)
function computeIndex($word)
{
- $lword = strtolower($word);
- $l = strlen($lword);
- for ($i=0;$i<$l;$i++)
- {
- $c = ord($lword{$i});
- $v = (($v & 0xfc00) ^ ($v << 6) ^ $c) & 0xffff;
- }
- return $v;
+ // Fast string hashing
+ //$lword = strtolower($word);
+ //$l = strlen($lword);
+ //for ($i=0;$i<$l;$i++)
+ //{
+ // $c = ord($lword{$i});
+ // $v = (($v & 0xfc00) ^ ($v << 6) ^ $c) & 0xffff;
+ //}
+ //return $v;
- //if (strlen($word)<2) return -1;
+ // Simple hashing that allows for substring search
+ if (strlen($word)<2) return -1;
// high char of the index
- //$hi = ord($word{0});
- //if ($hi==0) return -1;
+ $hi = ord($word{0});
+ if ($hi==0) return -1;
// low char of the index
- //$lo = ord($word{1});
- //if ($lo==0) return -1;
+ $lo = ord($word{1});
+ if ($lo==0) return -1;
// return index
- //return $hi*256+$lo;
+ return $hi*256+$lo;
}
function search($file,$word,&$statsList)
@@ -48,7 +50,7 @@ function search($file,$word,&$statsList)
{
fseek($file,$index*4+4); // 4 bytes per entry, skip header
$index = readInt($file);
- if ($index) // found words matching first two characters
+ if ($index) // found words matching the hash key
{
$start=sizeof($statsList);
$count=$start;