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

Side by Side Diff: runtime/lib/typed_data.dart

Issue 916153002: Improve _toInt64() and _toUint64() conversions in TypedData. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/bigint.dart ('k') | runtime/vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 classes for Int8List ..... Float64List and ByteData implementations. 5 // patch classes for Int8List ..... Float64List and ByteData implementations.
6 6
7 import "dart:_internal"; 7 import "dart:_internal";
8 import 'dart:math' show Random; 8 import 'dart:math' show Random;
9 9
10 patch class Int8List { 10 patch class Int8List {
(...skipping 3570 matching lines...) Expand 10 before | Expand all | Expand 10 after
3581 return _toInt(value, 0xFFFFFFFF); 3581 return _toInt(value, 0xFFFFFFFF);
3582 } 3582 }
3583 3583
3584 3584
3585 int _toUint32(int value) { 3585 int _toUint32(int value) {
3586 return value & 0xFFFFFFFF; 3586 return value & 0xFFFFFFFF;
3587 } 3587 }
3588 3588
3589 3589
3590 int _toInt64(int value) { 3590 int _toInt64(int value) {
3591 return _toInt(value, 0xFFFFFFFFFFFFFFFF); // TODO(regis): Avoid bigint mask. 3591 // Avoid bigint mask when possible.
3592 return (ClassID.getID(value) == ClassID.cidBigint) ?
3593 _toInt(value, 0xFFFFFFFFFFFFFFFF) : value;
3592 } 3594 }
3593 3595
3594 3596
3595 int _toUint64(int value) { 3597 int _toUint64(int value) {
3596 return value & 0xFFFFFFFFFFFFFFFF; // TODO(regis): Avoid bigint mask. 3598 // Avoid bigint mask when possible.
3599 return (ClassID.getID(value) == ClassID.cidBigint) ?
3600 _toInt(value, 0xFFFFFFFFFFFFFFFF) : value;
3597 } 3601 }
3598 3602
3599 3603
3600 void _rangeCheck(int listLength, int start, int length) { 3604 void _rangeCheck(int listLength, int start, int length) {
3601 if (length < 0) { 3605 if (length < 0) {
3602 throw new RangeError.value(length); 3606 throw new RangeError.value(length);
3603 } 3607 }
3604 if (start < 0) { 3608 if (start < 0) {
3605 throw new RangeError.value(start); 3609 throw new RangeError.value(start);
3606 } 3610 }
(...skipping 16 matching lines...) Expand all
3623 return value; 3627 return value;
3624 } 3628 }
3625 return object; 3629 return object;
3626 } 3630 }
3627 3631
3628 3632
3629 _newRangeError(int index, int length) { 3633 _newRangeError(int index, int length) {
3630 String message = "$index must be in the range [0..$length)"; 3634 String message = "$index must be in the range [0..$length)";
3631 return new RangeError(message); 3635 return new RangeError(message);
3632 } 3636 }
OLDNEW
« no previous file with comments | « runtime/lib/bigint.dart ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698