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

Unified Diff: sdk/lib/core/uri.dart

Issue 1406023018: Uri: use List.unmodifiable (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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/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;
}
/**
« 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