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

Unified Diff: runtime/lib/collection_patch.dart

Issue 336863008: Make the JSON decoder (parser) create Dart maps lazily (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address review feedback. Created 6 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 | « no previous file | sdk/lib/_internal/lib/convert_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/collection_patch.dart
diff --git a/runtime/lib/collection_patch.dart b/runtime/lib/collection_patch.dart
index e0bde4a5c61d984be421e883c69d9964dcb42521..6946681cd2d5cbacef944bf21e582ac7d8cd1513 100644
--- a/runtime/lib/collection_patch.dart
+++ b/runtime/lib/collection_patch.dart
@@ -174,9 +174,11 @@ class _HashMap<K, V> implements HashMap<K, V> {
}
void clear() {
- _elementCount = 0;
_buckets = new List(_INITIAL_CAPACITY);
- _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
+ if (_elementCount > 0) {
+ _elementCount = 0;
+ _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
+ }
}
void _removeEntry(_HashMapEntry entry,
@@ -673,9 +675,11 @@ class _HashSet<E> extends _HashSetBase<E> implements HashSet<E> {
}
void clear() {
- _elementCount = 0;
_buckets = new List(_INITIAL_CAPACITY);
- _modificationCount++;
+ if (_elementCount > 0) {
+ _elementCount = 0;
+ _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
+ }
}
void _addEntry(E key, int hashCode, int index) {
@@ -963,9 +967,11 @@ abstract class _LinkedHashMapMixin<K, V> implements LinkedHashMap<K, V> {
void clear() {
_nextEntry = _previousEntry = this;
- _elementCount = 0;
_buckets = new List(_HashMap._INITIAL_CAPACITY);
- _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
+ if (_elementCount > 0) {
+ _elementCount = 0;
+ _modificationCount = (_modificationCount + 1) & _MODIFICATION_COUNT_MASK;
+ }
}
void _addEntry(List buckets, int index, int length,
« no previous file with comments | « no previous file | sdk/lib/_internal/lib/convert_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698