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

Unified Diff: lib/src/hash_sink.dart

Issue 1825983002: Avoid calling ByteData.setUint64. (Closed) Base URL: git@github.com:dart-lang/crypto.git@master
Patch Set: Created 4 years, 9 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 | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/hash_sink.dart
diff --git a/lib/src/hash_sink.dart b/lib/src/hash_sink.dart
index a3cef94c4a9a17c760072dd87a84bac3a5dce16b..f4adcb3da61e7ffee13c474d69b22c6eaa7bde45 100644
--- a/lib/src/hash_sink.dart
+++ b/lib/src/hash_sink.dart
@@ -128,7 +128,20 @@ abstract class HashSink implements Sink<List<int>> {
// hash.
var offset = _pendingData.length;
_pendingData.addAll(new Uint8List(8));
- _pendingData.buffer.asByteData().setUint64(offset, lengthInBits, _endian);
+ var byteData = _pendingData.buffer.asByteData();
+
+ // We're essentially doing byteData.setUint64(offset, lengthInBits, _endian)
+ // here, but that method isn't supported on dart2js so we implement it
+ // manually instead.
+ var highBits = lengthInBits >> 32;
sra1 2016/03/23 22:15:50 This won't actually do what you want in dart2js. d
nweiz 2016/03/23 22:21:26 Presumably in dart2js, lengthInBits can't be highe
+ var lowBits = lengthInBits & mask32;
+ if (_endian == Endianness.BIG_ENDIAN) {
+ byteData.setUint32(offset, highBits, _endian);
+ byteData.setUint32(offset + bytesPerWord, lowBits, _endian);
+ } else {
+ byteData.setUint32(offset, lowBits, _endian);
+ byteData.setUint32(offset + bytesPerWord, highBits, _endian);
+ }
}
/// Rounds [val] up to the next multiple of [n], as long as [n] is a power of
« no previous file with comments | « CHANGELOG.md ('k') | pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698