Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Unified Diff: third_party/WebKit/Source/devtools/front_end/platform/utilities.js

Issue 1794473002: DevTools: Make the colors for the same URL be the same for all recording. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/devtools/front_end/platform/utilities.js
diff --git a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
index 808595e12c49acc659c79b44f61d16a429a08ceb..99a64e6e479c4a9ef5b89dc4a4428a0229d66f0c 100644
--- a/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
+++ b/third_party/WebKit/Source/devtools/front_end/platform/utilities.js
@@ -304,10 +304,21 @@ String.hashCode = function(string)
{
if (!string)
return 0;
- var result = 0;
- for (var i = 0; i < string.length; ++i)
- result = (result * 31 + string.charCodeAt(i)) | 0;
- return Math.abs(result);
+ // Hash algorithm for substrings is described in "Über die Komplexität der Multiplikation in
+ // eingeschränkten Branchingprogrammmodellen" by Woelfe.
+ // http://opendatastructures.org/versions/edition-0.1d/ods-java/node33.html#SECTION00832000000000000000
+ var p = ((1 << 30) * 4 - 5); // prime: 2^32 - 5
+ var z = 0x5033d967; // 32 bits from random.org
+ var z2 = 0x59d2f15d; // random odd 32 bit number
+ var s = 0;
+ var zi = 1;
+ for (var i = 0; i < string.length; i++) {
+ var xi = string.charCodeAt(i) * z2;
+ s = (s + zi * xi) % p;
+ zi = (zi * z) % p;
+ }
+ s = (s + zi * (p - 1)) % p;
+ return Math.abs(s|0);
}
/**
« no previous file with comments | « no previous file | third_party/WebKit/Source/devtools/front_end/ui_lazy/FlameChart.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698