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

Unified Diff: sdk/lib/_internal/js_runtime/lib/internal_patch.dart

Issue 2038853003: Specialize Symbol.hashCode (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | « runtime/lib/symbol_patch.dart ('k') | sdk/lib/internal/symbol.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/js_runtime/lib/internal_patch.dart
diff --git a/sdk/lib/_internal/js_runtime/lib/internal_patch.dart b/sdk/lib/_internal/js_runtime/lib/internal_patch.dart
index cb8820ce2b85f30b488deea77bc20316ff04a17c..a0c519f89911b2dc39b6f7c479a96888dd8b8529 100644
--- a/sdk/lib/_internal/js_runtime/lib/internal_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/internal_patch.dart
@@ -5,12 +5,23 @@
import 'dart:_js_primitives' show printString;
import 'dart:_js_helper' show patch;
import 'dart:_interceptors' show JSArray;
+import 'dart:_foreign_helper' show JS;
@patch
class Symbol implements core.Symbol {
@patch
const Symbol(String name)
: this._name = name;
+
+ @patch
+ int get hashCode {
+ int hash = JS('int|Null', '#._hashCode', this);
+ if (hash != null) return hash;
+ const arbitraryPrime = 664597;
+ hash = 0x1fffffff & (arbitraryPrime * _name.hashCode);
+ JS('', '#._hashCode = #', this, hash);
+ return hash;
+ }
}
@patch
« no previous file with comments | « runtime/lib/symbol_patch.dart ('k') | sdk/lib/internal/symbol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698