Skip to content

Commit

Permalink
[mms] Use more efficient FNV1-32 hashing algorithm for internal hasht…
Browse files Browse the repository at this point in the history
…able storage, if available.
  • Loading branch information
slusarz committed Feb 12, 2014
1 parent bd5f127 commit 71f4745
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions framework/Imap_Client/lib/Horde/Imap/Client/Base.php
Expand Up @@ -704,7 +704,10 @@ abstract protected function _noop();
public function getNamespaces(array $additional = array())
{
$additional = array_map('strval', $additional);
$sig = hash('sha1', serialize($additional));
$sig = hash(
(PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
json_encode($additional)
);

if (isset($this->_init['namespace'][$sig])) {
return $this->_init['namespace'][$sig];
Expand Down Expand Up @@ -2709,7 +2712,10 @@ private function _fetchWrapper($mailbox, $query, $options)
if (!empty($val['cache']) && !empty($val['peek'])) {
$cache_array[$k] = $v;
ksort($val);
$header_cache[$key] = hash('sha1', serialize($val));
$header_cache[$key] = hash(
(PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
serialize($val)
);
}
}
break;
Expand Down
5 changes: 4 additions & 1 deletion framework/Imap_Client/lib/Horde/Imap/Client/Fetch/Query.php
Expand Up @@ -292,7 +292,10 @@ public function remove($criteria, $key)
*/
public function hash()
{
return hash('sha1', serialize($this));
return hash(
(PHP_MINOR_VERSION >= 4) ? 'fnv132' : 'sha1',
serialize($this)
);
}

/* ArrayAccess methods. */
Expand Down
2 changes: 2 additions & 0 deletions framework/Imap_Client/package.xml
Expand Up @@ -21,6 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Use more efficient FNV1-32 hashing algorithm for internal hashtable storage, if available.
* [jan] Make SQL cache backend compatible with Oracle.
* [mms] Optimizations to IMAP tokenizer.
</notes>
Expand Down Expand Up @@ -2166,6 +2167,7 @@
<date>2014-02-11</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
* [mms] Use more efficient FNV1-32 hashing algorithm for internal hashtable storage, if available.
* [jan] Make SQL cache backend compatible with Oracle.
* [mms] Optimizations to IMAP tokenizer.
</notes>
Expand Down

0 comments on commit 71f4745

Please sign in to comment.