Use 4 byte integer from raw md5 instead of 5 hex representation chars
The hash is necessary as comparisons are significantly too slow otherwise. The old hash function used substr on the hexadecimal representation of the md5 hash, rather than the raw binary output. This wastes a significant amount of memory, as each byte can only be used to store up to 4 bit of information. The new hash has 32bit instead of 20bit and uses only a 4 byte integer instead of a 5 byte string.pull/4234/head
parent
5d7036e740
commit
15d572da4c
|
@ -55,12 +55,11 @@ class Rule
|
|||
$this->reasonData = $reasonData;
|
||||
|
||||
$this->disabled = false;
|
||||
|
||||
$this->job = $job;
|
||||
|
||||
$this->type = -1;
|
||||
|
||||
$this->ruleHash = substr(md5(implode(',', $this->literals)), 0, 5);
|
||||
$data = unpack('ihash', md5(implode(',', $this->literals), true));
|
||||
$this->ruleHash = $data['hash'];
|
||||
}
|
||||
|
||||
public function getHash()
|
||||
|
|
Loading…
Reference in New Issue