Skip to content

Commit

Permalink
Used Uint8List instead of List<int> for performance improvement.
Browse files Browse the repository at this point in the history
The method is called `fromBytes` so it's likely that the parameter passed will be of type `Uint8List`. Now the `List.setRange()` implementation will copy the list element-wise, while `Uint8List.setRange()`, when passed another `Uint8List`, will use native code optimized to copy arbitrarily sized chunks of bytes.
  • Loading branch information
stevenroose committed Sep 3, 2014
1 parent 5e1ef43 commit 6b3c4e1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/bignum.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library bignum;

import 'dart:math' as Mathx;
import 'dart:typed_data';
part 'src/BigInteger_v8/big_integer.dart';
2 changes: 1 addition & 1 deletion lib/src/BigInteger_v8/big_integer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class BigInteger {
// Add a leading 0 if most significant bit set (otherwise, the magnitude
// is interpreted as negative and this constructor fails)
if( (magnitude[0] & 0x80) != 0 ) {
magnitude = new List<int>(1+magnitude.length)
magnitude = new Uint8List(1+magnitude.length)
..[0] = 0
..setRange(1, 1+magnitude.length, magnitude);
}
Expand Down

0 comments on commit 6b3c4e1

Please sign in to comment.