Skip to content

Commit e984c55

Browse files
committed
use putIfAbsent return value
1 parent a086028 commit e984c55

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

lib/src/asset/cache.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,11 @@ class CachedAssetReader extends AssetReader {
6060
Future<bool> hasInput(AssetId id) {
6161
if (_cache.contains(id)) return new Future.value(true);
6262

63-
_pendingHasInputChecks.putIfAbsent(id, () async {
63+
return _pendingHasInputChecks.putIfAbsent(id, () async {
6464
var exists = await _reader.hasInput(id);
6565
_pendingHasInputChecks.remove(id);
6666
return exists;
6767
});
68-
return _pendingHasInputChecks[id];
6968
}
7069

7170
@override
@@ -74,13 +73,12 @@ class CachedAssetReader extends AssetReader {
7473
return new Future.value(_cache.get(id).stringContents);
7574
}
7675

77-
_pendingReads.putIfAbsent(id, () async {
76+
return _pendingReads.putIfAbsent(id, () async {
7877
var content = await _reader.readAsString(id, encoding: encoding);
7978
_cache.put(new Asset(id, content));
8079
_pendingReads.remove(id);
8180
return content;
8281
});
83-
return _pendingReads[id];
8482
}
8583

8684
@override

0 commit comments

Comments
 (0)