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

Unified Diff: base/files/file_path.cc

Issue 2500473002: [base::FilePath] Optimize FilePath::ReferencesParent (Closed)
Patch Set: Created 4 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: base/files/file_path.cc
diff --git a/base/files/file_path.cc b/base/files/file_path.cc
index 0b06493c8831f485a06e169167dfb802fc188dd5..cff862ae19da14bd59cffe64724027a3f2c16ed6 100644
--- a/base/files/file_path.cc
+++ b/base/files/file_path.cc
@@ -560,6 +560,12 @@ FilePath FilePath::StripTrailingSeparators() const {
}
bool FilePath::ReferencesParent() const {
+ if (path_.find(kParentDirectory) == StringType::npos) {
+ // GetComponents is quite expensive, so avoid calling it in the majority
+ // of cases where there isn't a kParentDirectory anywhere in the path.
+ return false;
+ }
+
std::vector<StringType> components;
danakj 2016/11/11 19:17:40 This is great! Question tho: We should probably u
jkarlin 2016/11/11 19:38:24 Are you suggesting that GetComponents should take
danakj 2016/11/11 19:57:27 Ah ok, it's not trivial at all np. This LGTM!
GetComponents(&components);
« 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