Index: sdk/lib/core/uri.dart |
diff --git a/sdk/lib/core/uri.dart b/sdk/lib/core/uri.dart |
index 3abd352c1ae8e120a6934fe312c064132de29af1..4cfe9f4f926237aa85999588bd0583a4a63138e0 100644 |
--- a/sdk/lib/core/uri.dart |
+++ b/sdk/lib/core/uri.dart |
@@ -1018,17 +1018,18 @@ class Uri { |
* calls that would mutate it. |
*/ |
List<String> get pathSegments { |
- if (_pathSegments == null) { |
- var pathToSplit = !path.isEmpty && path.codeUnitAt(0) == _SLASH |
- ? path.substring(1) |
- : path; |
- _pathSegments = new UnmodifiableListView( |
- pathToSplit == "" ? const<String>[] |
- : pathToSplit.split("/") |
- .map(Uri.decodeComponent) |
- .toList(growable: false)); |
- } |
- return _pathSegments; |
+ var result = _pathSegments; |
+ if (result != null) return result; |
+ |
+ 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
|
+ ? path.substring(1) |
+ : path; |
+ 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.
|
+ ? const<String>[] |
+ : new List<String>.unmodifiable( |
+ pathToSplit.split("/").map(Uri.decodeComponent)); |
+ _pathSegments = result; |
+ return result; |
} |
/** |