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

Unified Diff: sdk/lib/io/http_impl.dart

Issue 11299005: Avoid repeated lower-casing of the same string when adding HTTP (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/io/http_impl.dart
diff --git a/sdk/lib/io/http_impl.dart b/sdk/lib/io/http_impl.dart
index 2de2e0052c54bc017b3820631f2465af1186d3b0..19adf28b06bf2377ee4197f1250f8213690f9d5a 100644
--- a/sdk/lib/io/http_impl.dart
+++ b/sdk/lib/io/http_impl.dart
@@ -153,8 +153,9 @@ class _HttpHeaders implements HttpHeaders {
}
void _add(String name, Object value) {
+ var lowerCaseName = name.toLowerCase();
// TODO(sgjesse): Add immutable state throw HttpException is immutable.
- if (name.toLowerCase() == "date") {
+ if (lowerCaseName == "date") {
if (value is Date) {
date = value;
} else if (value is String) {
@@ -162,7 +163,7 @@ class _HttpHeaders implements HttpHeaders {
} else {
throw new HttpException("Unexpected type for header named $name");
}
- } else if (name.toLowerCase() == "expires") {
+ } else if (lowerCaseName == "expires") {
if (value is Date) {
expires = value;
} else if (value is String) {
@@ -170,7 +171,7 @@ class _HttpHeaders implements HttpHeaders {
} else {
throw new HttpException("Unexpected type for header named $name");
}
- } else if (name.toLowerCase() == "if-modified-since") {
+ } else if (lowerCaseName == "if-modified-since") {
if (value is Date) {
ifModifiedSince = value;
} else if (value is String) {
@@ -178,7 +179,7 @@ class _HttpHeaders implements HttpHeaders {
} else {
throw new HttpException("Unexpected type for header named $name");
}
- } else if (name.toLowerCase() == "host") {
+ } else if (lowerCaseName == "host") {
int pos = value.indexOf(":");
if (pos == -1) {
_host = value;
@@ -200,10 +201,10 @@ class _HttpHeaders implements HttpHeaders {
}
_set("host", value);
}
- } else if (name.toLowerCase() == "content-type") {
+ } else if (lowerCaseName == "content-type") {
_set("content-type", value);
} else {
- name = name.toLowerCase();
+ name = lowerCaseName;
Søren Gjesse 2012/11/15 12:24:11 This line is not needed. Just use lowerCaseName tw
List<String> values = _headers[name];
if (values == null) {
values = new List<String>();
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698