PY-15476 Details about using Python String.hashCode() implementation in generator3.py as hash for directory paths added

This commit is contained in:
Alexander Koshevoy
2015-09-18 15:04:54 +03:00
parent 0efaff1d51
commit dffdc1e97b
+4 -3
View File
@@ -165,7 +165,7 @@ def list_sources(paths, target_path):
if path.endswith('.egg') and os.path.isfile(path):
say("%s\t%s\t%d", path, path, os.path.getsize(path))
target_dir_hash = str(java_string_hashcode(path))
target_dir_hash = str(compute_path_hash(path))
for root, files in walk_python_path(path):
for name in files:
@@ -186,9 +186,10 @@ def list_sources(paths, target_path):
traceback.print_exc()
sys.exit(1)
def java_string_hashcode(s):
def compute_path_hash(path):
# computes hash for provided path following contract of Java String's hashCode() method
h = 0
for c in s:
for c in path:
h = (31 * h + ord(c)) & 0xFFFFFFFF
return ((h + 0x80000000) & 0xFFFFFFFF) - 0x80000000