| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 // Patch file for dart:convert library. | 5 // Patch file for dart:convert library. |
| 6 | 6 |
| 7 import 'dart:_js_helper' show patch; | 7 import 'dart:_js_helper' show patch; |
| 8 import 'dart:_foreign_helper' show JS; | 8 import 'dart:_foreign_helper' show JS; |
| 9 import 'dart:_interceptors' show JSExtendableArray; | 9 import 'dart:_interceptors' show JSExtendableArray; |
| 10 import 'dart:_internal' show MappedIterable, ListIterable; | 10 import 'dart:_internal' show MappedIterable, ListIterable; |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 // We keep track of the map entries that we have already | 133 // We keep track of the map entries that we have already |
| 134 // processed by adding them to a separate JavaScript object. | 134 // processed by adding them to a separate JavaScript object. |
| 135 var _processed = _newJavaScriptObject(); | 135 var _processed = _newJavaScriptObject(); |
| 136 | 136 |
| 137 // If the data slot isn't null, it represents either the list | 137 // If the data slot isn't null, it represents either the list |
| 138 // of keys (for non-upgraded JSON maps) or the upgraded map. | 138 // of keys (for non-upgraded JSON maps) or the upgraded map. |
| 139 var _data = null; | 139 var _data = null; |
| 140 | 140 |
| 141 _JsonMap(this._original); | 141 _JsonMap(this._original); |
| 142 | 142 |
| 143 operator[](key) { | 143 operator[](Object key) { |
| 144 if (_isUpgraded) { | 144 if (_isUpgraded) { |
| 145 return _upgradedMap[key]; | 145 return _upgradedMap[key]; |
| 146 } else if (key is !String) { | 146 } else if (key is !String) { |
| 147 return null; | 147 return null; |
| 148 } else { | 148 } else { |
| 149 var result = _getProperty(_processed, key); | 149 var result = _getProperty(_processed, key); |
| 150 if (_isUnprocessed(result)) result = _process(key); | 150 if (_isUnprocessed(result)) result = _process(key); |
| 151 return result; | 151 return result; |
| 152 } | 152 } |
| 153 } | 153 } |
| (...skipping 29 matching lines...) Expand all Loading... |
| 183 _upgrade()[key] = value; | 183 _upgrade()[key] = value; |
| 184 } | 184 } |
| 185 } | 185 } |
| 186 | 186 |
| 187 void addAll(Map other) { | 187 void addAll(Map other) { |
| 188 other.forEach((key, value) { | 188 other.forEach((key, value) { |
| 189 this[key] = value; | 189 this[key] = value; |
| 190 }); | 190 }); |
| 191 } | 191 } |
| 192 | 192 |
| 193 bool containsValue(value) { | 193 bool containsValue(Object value) { |
| 194 if (_isUpgraded) return _upgradedMap.containsValue(value); | 194 if (_isUpgraded) return _upgradedMap.containsValue(value); |
| 195 List<String> keys = _computeKeys(); | 195 List<String> keys = _computeKeys(); |
| 196 for (int i = 0; i < keys.length; i++) { | 196 for (int i = 0; i < keys.length; i++) { |
| 197 String key = keys[i]; | 197 String key = keys[i]; |
| 198 if (this[key] == value) return true; | 198 if (this[key] == value) return true; |
| 199 } | 199 } |
| 200 return false; | 200 return false; |
| 201 } | 201 } |
| 202 | 202 |
| 203 bool containsKey(key) { | 203 bool containsKey(Object key) { |
| 204 if (_isUpgraded) return _upgradedMap.containsKey(key); | 204 if (_isUpgraded) return _upgradedMap.containsKey(key); |
| 205 if (key is !String) return false; | 205 if (key is !String) return false; |
| 206 return _hasProperty(_original, key); | 206 return _hasProperty(_original, key); |
| 207 } | 207 } |
| 208 | 208 |
| 209 putIfAbsent(key, ifAbsent()) { | 209 putIfAbsent(key, ifAbsent()) { |
| 210 if (containsKey(key)) return this[key]; | 210 if (containsKey(key)) return this[key]; |
| 211 var value = ifAbsent(); | 211 var value = ifAbsent(); |
| 212 this[key] = value; | 212 this[key] = value; |
| 213 return value; | 213 return value; |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 _sink.close(); | 394 _sink.close(); |
| 395 } | 395 } |
| 396 } | 396 } |
| 397 | 397 |
| 398 @patch class Utf8Decoder { | 398 @patch class Utf8Decoder { |
| 399 @patch | 399 @patch |
| 400 Converter<List<int>,dynamic> fuse(Converter<String, dynamic> next) { | 400 Converter<List<int>,dynamic> fuse(Converter<String, dynamic> next) { |
| 401 return super.fuse(next); | 401 return super.fuse(next); |
| 402 } | 402 } |
| 403 } | 403 } |
| OLD | NEW |