Skip to content

Commit

Permalink
Bug 1648129 - Use faster hash for ipdl generator r=froydnj
Browse files Browse the repository at this point in the history
`adler32` is about 3x as fast overall as `md5` on my machine.

Differential Revision: https://phabricator.services.mozilla.com/D81892
  • Loading branch information
Ricky Stewart committed Jul 1, 2020
1 parent dd8be77 commit 8fe4350
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions ipc/ipdl/ipdl/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

import hashlib
import zlib


# The built-in hash over the str type is non-deterministic, so we need to do
# this instead.
def hash_str(s):
assert isinstance(s, str)
return int.from_bytes(hashlib.md5(s.encode('utf-8')).digest(),
byteorder='big')
return zlib.adler32(s.encode('utf-8'))

0 comments on commit 8fe4350

Please sign in to comment.