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

Unified Diff: sdk/lib/_internal/lib/js_helper.dart

Issue 271193002: Avoid prototype properties in JS-Object caches. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use Object.create Created 6 years, 7 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 | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/lib/js_helper.dart
diff --git a/sdk/lib/_internal/lib/js_helper.dart b/sdk/lib/_internal/lib/js_helper.dart
index 1b19fbfb405b423cda42b97a9c1ca95ff841a77f..2592a72db5ab0712139849d897bec62e96cb81c3 100644
--- a/sdk/lib/_internal/lib/js_helper.dart
+++ b/sdk/lib/_internal/lib/js_helper.dart
@@ -1097,16 +1097,19 @@ class Primitives {
class JsCache {
/// Returns a JavaScript object suitable for use as a cache.
static allocate() {
- var result = JS('=Object', '{x:0}');
+ var result = JS('=Object', 'Object.create(null)');
// Deleting a property makes V8 assume that it shouldn't create a hidden
// class for [result] and map transitions. Although these map transitions
// pay off if there are many cache hits for the same keys, it becomes
// really slow when there aren't many repeated hits.
+ JS('void', '#.x=0', result);
JS('void', 'delete #.x', result);
return result;
}
- static fetch(cache, String key) => JS('', '#[#]', cache, key);
+ static fetch(cache, String key) {
+ return JS('', '#[#]', cache, key);
+ }
static void update(cache, String key, value) {
JS('void', '#[#] = #', cache, key, value);
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/js_mirrors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698