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

Side by Side Diff: pkg/dev_compiler/tool/input_sdk/patch/core_patch.dart

Issue 2994203002: Optimize DDC private library files. (Closed)
Patch Set: Small tweaks Created 3 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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:core classes. 5 // Patch file for dart:core classes.
6 import "dart:_internal" as _symbol_dev; 6 import "dart:_internal" as _symbol_dev;
7 import 'dart:_interceptors'; 7 import 'dart:_interceptors';
8 import 'dart:_js_helper' 8 import 'dart:_js_helper'
9 show 9 show
10 patch, 10 patch,
11 checkInt, 11 checkInt,
12 getRuntimeType, 12 getRuntimeType,
13 getTraceFromException, 13 getTraceFromException,
14 jsonEncodeNative, 14 jsonEncodeNative,
15 JsLinkedHashMap, 15 JsLinkedHashMap,
16 JSSyntaxRegExp, 16 JSSyntaxRegExp,
17 NoInline, 17 NoInline,
18 notNull,
19 nullCheck,
18 objectHashCode, 20 objectHashCode,
19 Primitives, 21 Primitives,
20 stringJoinUnchecked; 22 stringJoinUnchecked;
21 23
22 import 'dart:_foreign_helper' show JS; 24 import 'dart:_foreign_helper' show JS;
23 25
24 import 'dart:_native_typed_data' show NativeUint8List; 26 import 'dart:_native_typed_data' show NativeUint8List;
25 27
26 String _symbolToString(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); 28 String _symbolToString(Symbol symbol) => _symbol_dev.Symbol.getName(symbol);
27 29
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 } 314 }
313 315
314 @patch 316 @patch
315 static int _now() => Primitives.timerTicks(); 317 static int _now() => Primitives.timerTicks();
316 } 318 }
317 319
318 // Patch for List implementation. 320 // Patch for List implementation.
319 @patch 321 @patch
320 class List<E> { 322 class List<E> {
321 @patch 323 @patch
322 factory List([int length]) { 324 factory List([int _length]) {
323 dynamic list; 325 dynamic list;
324 if (length == null) { 326 if (_length == null) {
325 list = JS('', '[]'); 327 list = JS('', '[]');
326 } else { 328 } else {
327 // Explicit type test is necessary to guard against JavaScript conversions 329 @notNull
328 // in unchecked mode. 330 var length = _length;
329 if ((length is! int) || (length < 0)) { 331 if (length < 0) {
330 throw new ArgumentError( 332 throw new ArgumentError(
331 "Length must be a non-negative integer: $length"); 333 "Length must be a non-negative integer: $length");
332 } 334 }
333 list = JSArray.markFixedList(JS('', 'new Array(#)', length)); 335 list = JSArray.markFixedList(JS('', 'new Array(#)', length));
334 } 336 }
335 return new JSArray<E>.of(list); 337 return new JSArray<E>.of(list);
336 } 338 }
337 339
338 @patch 340 @patch
339 factory List.filled(int length, E fill, {bool growable: true}) { 341 factory List.filled(int length, E fill, {bool growable: true}) {
340 List<E> result = new List<E>(length); 342 List<E> result = new List<E>(length);
341 if (length != 0 && fill != null) { 343 if (length != 0 && fill != null) {
342 for (int i = 0; i < result.length; i++) { 344 @notNull
345 var length = result.length;
346 for (int i = 0; i < length; i++) {
343 result[i] = fill; 347 result[i] = fill;
344 } 348 }
345 } 349 }
346 if (growable) return result; 350 if (growable) return result;
347 return makeListFixedLength/*<E>*/(result); 351 return makeListFixedLength<E>(result);
348 } 352 }
349 353
350 @patch 354 @patch
351 factory List.from(Iterable elements, {bool growable: true}) { 355 factory List.from(Iterable elements, {bool growable: true}) {
352 List<E> list = new List<E>(); 356 List<E> list = new List<E>();
353 for (var e in elements) { 357 // Specialize the copy loop for the case that doesn't need a
354 list.add(e); 358 // runtime check.
359 if (elements is Iterable<E>) {
360 for (var e in elements) {
361 list.add(e);
362 }
363 } else {
364 for (var e in elements) {
365 list.add(e);
Jennifer Messerly 2017/08/22 21:54:40 make `as E` explicit? I'm thinking of disabling i
Leaf 2017/08/23 17:26:13 Done.
366 }
355 } 367 }
356 if (growable) return list; 368 if (growable) return list;
357 return makeListFixedLength/*<E>*/(list); 369 return makeListFixedLength/*<E>*/(list);
358 } 370 }
359 371
360 @patch 372 @patch
361 factory List.unmodifiable(Iterable elements) { 373 factory List.unmodifiable(Iterable elements) {
362 var result = new List<E>.from(elements, growable: false); 374 var result = new List<E>.from(elements, growable: false);
363 return makeFixedListUnmodifiable/*<E>*/(result); 375 return makeFixedListUnmodifiable/*<E>*/(result);
364 } 376 }
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 static StackTrace get current { 668 static StackTrace get current {
657 return getTraceFromException(JS('', 'new Error()')); 669 return getTraceFromException(JS('', 'new Error()'));
658 } 670 }
659 } 671 }
660 672
661 @patch 673 @patch
662 class _ConstantExpressionError { 674 class _ConstantExpressionError {
663 @patch 675 @patch
664 _throw(error) => throw error; 676 _throw(error) => throw error;
665 } 677 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698