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

Side by Side Diff: sdk/lib/io/http_headers.dart

Issue 75033003: Don't use linked maps/sets in http internals. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 part of dart.io; 5 part of dart.io;
6 6
7 class _HttpHeaders implements HttpHeaders { 7 class _HttpHeaders implements HttpHeaders {
8 _HttpHeaders(String this.protocolVersion) 8 _HttpHeaders(String this.protocolVersion)
9 : _headers = new Map<String, List<String>>(); 9 : _headers = new HashMap<String, List<String>>();
10 10
11 List<String> operator[](String name) { 11 List<String> operator[](String name) {
12 name = name.toLowerCase(); 12 name = name.toLowerCase();
13 return _headers[name]; 13 return _headers[name];
14 } 14 }
15 15
16 String value(String name) { 16 String value(String name) {
17 name = name.toLowerCase(); 17 name = name.toLowerCase();
18 List<String> values = _headers[name]; 18 List<String> values = _headers[name];
19 if (values == null) return null; 19 if (values == null) return null;
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 477 }
478 478
479 479
480 class _HeaderValue implements HeaderValue { 480 class _HeaderValue implements HeaderValue {
481 String _value; 481 String _value;
482 _UnmodifiableMap<String, String> _parameters; 482 _UnmodifiableMap<String, String> _parameters;
483 483
484 _HeaderValue([String this._value = "", Map<String, String> parameters]) { 484 _HeaderValue([String this._value = "", Map<String, String> parameters]) {
485 if (parameters != null) { 485 if (parameters != null) {
486 _parameters = 486 _parameters =
487 new _UnmodifiableMap(new Map<String, String>.from(parameters)); 487 new _UnmodifiableMap(new HashMap<String, String>.from(parameters));
488 } 488 }
489 } 489 }
490 490
491 static _HeaderValue parse(String value, 491 static _HeaderValue parse(String value,
492 {parameterSeparator: ";", 492 {parameterSeparator: ";",
493 preserveBackslash: false}) { 493 preserveBackslash: false}) {
494 // Parse the string. 494 // Parse the string.
495 var result = new _HeaderValue(); 495 var result = new _HeaderValue();
496 result._parse(value, parameterSeparator, preserveBackslash); 496 result._parse(value, parameterSeparator, preserveBackslash);
497 return result; 497 return result;
498 } 498 }
499 499
500 String get value => _value; 500 String get value => _value;
501 501
502 void _ensureParameters() { 502 void _ensureParameters() {
503 if (_parameters == null) { 503 if (_parameters == null) {
504 _parameters = new _UnmodifiableMap(new Map<String, String>()); 504 _parameters = new _UnmodifiableMap(new HashMap<String, String>());
505 } 505 }
506 } 506 }
507 507
508 Map<String, String> get parameters { 508 Map<String, String> get parameters {
509 _ensureParameters(); 509 _ensureParameters();
510 return _parameters; 510 return _parameters;
511 } 511 }
512 512
513 String toString() { 513 String toString() {
514 StringBuffer sb = new StringBuffer(); 514 StringBuffer sb = new StringBuffer();
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 throw new HttpException("Failed to parse header value"); 552 throw new HttpException("Failed to parse header value");
553 } 553 }
554 index++; 554 index++;
555 } 555 }
556 556
557 void maybeExpect(String expected) { 557 void maybeExpect(String expected) {
558 if (s[index] == expected) index++; 558 if (s[index] == expected) index++;
559 } 559 }
560 560
561 void parseParameters() { 561 void parseParameters() {
562 var parameters = new Map<String, String>(); 562 var parameters = new HashMap<String, String>();
563 _parameters = new _UnmodifiableMap(parameters); 563 _parameters = new _UnmodifiableMap(parameters);
564 564
565 String parseParameterName() { 565 String parseParameterName() {
566 int start = index; 566 int start = index;
567 while (!done()) { 567 while (!done()) {
568 if (s[index] == " " || s[index] == "\t" || s[index] == "=") break; 568 if (s[index] == " " || s[index] == "\t" || s[index] == "=") break;
569 index++; 569 index++;
570 } 570 }
571 return s.substring(start, index).toLowerCase(); 571 return s.substring(start, index).toLowerCase();
572 } 572 }
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 void clear() { 828 void clear() {
829 throw new UnsupportedError("Cannot modify an unmodifiable map"); 829 throw new UnsupportedError("Cannot modify an unmodifiable map");
830 } 830 }
831 void forEach(void f(K key, V value)) => _map.forEach(f); 831 void forEach(void f(K key, V value)) => _map.forEach(f);
832 Iterable<K> get keys => _map.keys; 832 Iterable<K> get keys => _map.keys;
833 Iterable<V> get values => _map.values; 833 Iterable<V> get values => _map.values;
834 int get length => _map.length; 834 int get length => _map.length;
835 bool get isEmpty => _map.isEmpty; 835 bool get isEmpty => _map.isEmpty;
836 bool get isNotEmpty => _map.isNotEmpty; 836 bool get isNotEmpty => _map.isNotEmpty;
837 } 837 }
OLDNEW
« no previous file with comments | « no previous file | sdk/lib/io/http_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698