Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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.core; | 5 part of dart.core; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A parsed URI, such as a URL. | 8 * A parsed URI, such as a URL. |
| 9 * | 9 * |
| 10 * **See also:** | 10 * **See also:** |
| (...skipping 1000 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1011 /** | 1011 /** |
| 1012 * Returns the URI path split into its segments. Each of the | 1012 * Returns the URI path split into its segments. Each of the |
| 1013 * segments in the returned list have been decoded. If the path is | 1013 * segments in the returned list have been decoded. If the path is |
| 1014 * empty the empty list will be returned. A leading slash `/` does | 1014 * empty the empty list will be returned. A leading slash `/` does |
| 1015 * not affect the segments returned. | 1015 * not affect the segments returned. |
| 1016 * | 1016 * |
| 1017 * The returned list is unmodifiable and will throw [UnsupportedError] on any | 1017 * The returned list is unmodifiable and will throw [UnsupportedError] on any |
| 1018 * calls that would mutate it. | 1018 * calls that would mutate it. |
| 1019 */ | 1019 */ |
| 1020 List<String> get pathSegments { | 1020 List<String> get pathSegments { |
| 1021 if (_pathSegments == null) { | 1021 var result = _pathSegments; |
| 1022 var pathToSplit = !path.isEmpty && path.codeUnitAt(0) == _SLASH | 1022 if (result != null) return result; |
| 1023 ? path.substring(1) | 1023 |
| 1024 : path; | 1024 var pathToSplit = !path.isEmpty && path.codeUnitAt(0) == _SLASH |
|
Lasse Reichstein Nielsen
2015/11/04 06:54:56
Alternatively (I have no idea if it's better perfo
sra1
2015/11/04 22:29:03
I measured a small (5%) degradation for this patte
| |
| 1025 _pathSegments = new UnmodifiableListView( | 1025 ? path.substring(1) |
| 1026 pathToSplit == "" ? const<String>[] | 1026 : path; |
| 1027 : pathToSplit.split("/") | 1027 result = pathToSplit == "" |
|
Lasse Reichstein Nielsen
2015/11/04 06:54:56
Parenthesize the condition (or change to .isEmpty)
sra1
2015/11/04 22:29:03
Done.
| |
| 1028 .map(Uri.decodeComponent) | 1028 ? const<String>[] |
| 1029 .toList(growable: false)); | 1029 : new List<String>.unmodifiable( |
| 1030 } | 1030 pathToSplit.split("/").map(Uri.decodeComponent)); |
| 1031 return _pathSegments; | 1031 _pathSegments = result; |
| 1032 return result; | |
| 1032 } | 1033 } |
| 1033 | 1034 |
| 1034 /** | 1035 /** |
| 1035 * Returns the URI query split into a map according to the rules | 1036 * Returns the URI query split into a map according to the rules |
| 1036 * specified for FORM post in the [HTML 4.01 specification section 17.13.4] | 1037 * specified for FORM post in the [HTML 4.01 specification section 17.13.4] |
| 1037 * (http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4 | 1038 * (http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4 |
| 1038 * "HTML 4.01 section 17.13.4"). Each key and value in the returned map | 1039 * "HTML 4.01 section 17.13.4"). Each key and value in the returned map |
| 1039 * has been decoded. If there is no query the empty map is returned. | 1040 * has been decoded. If there is no query the empty map is returned. |
| 1040 * | 1041 * |
| 1041 * Keys in the query string that have no value are mapped to the | 1042 * Keys in the query string that have no value are mapped to the |
| (...skipping 1569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2611 0xafff, // 0x30 - 0x3f 1111111111110101 | 2612 0xafff, // 0x30 - 0x3f 1111111111110101 |
| 2612 // @ABCDEFGHIJKLMNO | 2613 // @ABCDEFGHIJKLMNO |
| 2613 0xffff, // 0x40 - 0x4f 1111111111111111 | 2614 0xffff, // 0x40 - 0x4f 1111111111111111 |
| 2614 // PQRSTUVWXYZ _ | 2615 // PQRSTUVWXYZ _ |
| 2615 0x87ff, // 0x50 - 0x5f 1111111111100001 | 2616 0x87ff, // 0x50 - 0x5f 1111111111100001 |
| 2616 // abcdefghijklmno | 2617 // abcdefghijklmno |
| 2617 0xfffe, // 0x60 - 0x6f 0111111111111111 | 2618 0xfffe, // 0x60 - 0x6f 0111111111111111 |
| 2618 // pqrstuvwxyz ~ | 2619 // pqrstuvwxyz ~ |
| 2619 0x47ff]; // 0x70 - 0x7f 1111111111100010 | 2620 0x47ff]; // 0x70 - 0x7f 1111111111100010 |
| 2620 } | 2621 } |
| OLD | NEW |