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

Unified Diff: pkg/analyzer/lib/src/summary/incremental_cache.dart

Issue 2041963002: Start using crypto 1.1.1 and tweak MD5 computation. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 6 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 | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/summary/incremental_cache.dart
diff --git a/pkg/analyzer/lib/src/summary/incremental_cache.dart b/pkg/analyzer/lib/src/summary/incremental_cache.dart
index 1d913be954c87144c5271fb6c9bfef26d41c5f7f..379b9ae64d8e2731d48c4227054df9dbc002ee9d 100644
--- a/pkg/analyzer/lib/src/summary/incremental_cache.dart
+++ b/pkg/analyzer/lib/src/summary/incremental_cache.dart
@@ -2,7 +2,7 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-import 'dart:convert' show ChunkedConversionSink, UTF8;
+import 'dart:convert';
import 'dart:core' hide Resource;
import 'package:analyzer/dart/element/element.dart';
@@ -220,6 +220,21 @@ class IncrementalCache {
}
}
+ List<int> _computeSaltedMD5OfBytes(addData(ByteConversionSink byteSink)) {
+ Digest digest;
+ ChunkedConversionSink<Digest> digestSink =
+ new ChunkedConversionSink<Digest>.withCallback((List<Digest> digests) {
+ digest = digests.single;
+ });
+ ByteConversionSink byteSink = md5.startChunkedConversion(digestSink);
+ // Add data.
+ addData(byteSink);
+ byteSink.add(configSalt);
+ // Done.
+ byteSink.close();
+ return digest.bytes;
+ }
+
/**
* Get the content based information about the given [source], maybe `null`
* if the information is not in the cache.
@@ -292,31 +307,12 @@ class IncrementalCache {
List<int> _getLibraryClosureHash(Source librarySource) {
return _libraryClosureHashMap.putIfAbsent(librarySource, () {
List<Source> closure = _getLibraryClosure(librarySource);
-
- Digest digest;
-
- var digestSink = new ChunkedConversionSink<Digest>.withCallback(
- (List<Digest> digests) {
- digest = digests.single;
+ return _computeSaltedMD5OfBytes((ByteConversionSink byteSink) {
+ for (Source source in closure) {
+ List<int> sourceHash = _getSourceContentHash(source);
+ byteSink.add(sourceHash);
+ }
});
-
- var byteSink = md5.startChunkedConversion(digestSink);
-
- for (Source source in closure) {
- List<int> sourceHash = _getSourceContentHash(source);
- byteSink.add(sourceHash);
- }
- byteSink.add(configSalt);
-
- byteSink.close();
- // TODO(paulberry): this call to `close` should not be needed.
- // Can be removed once
- // https://github.com/dart-lang/crypto/issues/33
- // is fixed – ensure the min version constraint on crypto is updated, tho.
- // Does not cause any problems in the mean time.
- digestSink.close();
-
- return digest.bytes;
});
}
« no previous file with comments | « no previous file | pkg/analyzer/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698