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

Unified Diff: pkg/shelf/lib/src/shelf_unmodifiable_map.dart

Issue 366063002: pkg/shelf: Updated headers map to use pkg/collection CanonicalizedMap (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: cl nit Created 6 years, 5 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 | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/shelf/lib/src/shelf_unmodifiable_map.dart
diff --git a/pkg/shelf/lib/src/shelf_unmodifiable_map.dart b/pkg/shelf/lib/src/shelf_unmodifiable_map.dart
index 9634c8538a12a790489c3a8f432afeeb2b28d02d..7cb5553e3036348ed42e7e1ca79bbf983f0d01c6 100644
--- a/pkg/shelf/lib/src/shelf_unmodifiable_map.dart
+++ b/pkg/shelf/lib/src/shelf_unmodifiable_map.dart
@@ -6,8 +6,6 @@ library shelf.shelf_unmodifiable_map;
import 'dart:collection';
-// TODO(kevmoo): MapView lacks a const ctor, so we have to use DelegatingMap
-// from pkg/collection - https://codereview.chromium.org/294093003/
import 'package:collection/wrappers.dart' as pc;
/// A simple wrapper over [pc.UnmodifiableMapView] which avoids re-wrapping
@@ -33,15 +31,8 @@ class ShelfUnmodifiableMap<V> extends UnmodifiableMapView<String, V> {
}
if (ignoreKeyCase) {
- // TODO(kevmoo) generalize this model with a 'canonical map' to align with
- // similiar implementation in http pkg [BaseRequest].
- var map = new LinkedHashMap<String, V>(
- equals: (key1, key2) => key1.toLowerCase() == key2.toLowerCase(),
- hashCode: (key) => key.toLowerCase().hashCode);
-
- map.addAll(source);
-
- source = map;
+ source = new pc.CanonicalizedMap<String, String, V>.from(source,
+ (key) => key.toLowerCase(), isValidKey: (key) => key != null);
} else {
source = new Map<String, V>.from(source);
}
@@ -53,6 +44,8 @@ class ShelfUnmodifiableMap<V> extends UnmodifiableMapView<String, V> {
}
/// An const empty implementation of [ShelfUnmodifiableMap].
+// TODO(kevmoo): Consider using MapView from dart:collection which has a const
+// ctor. Would require updating min SDK to 1.5.
class _EmptyShelfUnmodifiableMap<V> extends pc.DelegatingMap<String, V>
implements ShelfUnmodifiableMap<V> {
const _EmptyShelfUnmodifiableMap() : super(const {});
« no previous file with comments | « pkg/shelf/CHANGELOG.md ('k') | pkg/shelf/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698