Skip to content

Commit 1945da4

Browse files
committed
intercept: small performance improvement
1 parent c703e58 commit 1945da4

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

source/intercept/source/collect/Session.cc

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,19 @@ namespace ic {
5050

5151
std::string Session::keep_front_in_path(const std::string& path, const std::string& paths)
5252
{
53-
std::list<fs::path> result = {path};
54-
55-
auto existing = sys::path::split(paths);
56-
std::copy_if(existing.begin(), existing.end(),
57-
std::back_inserter(result),
58-
[&path](auto current) { return current != path; }
59-
);
60-
61-
return sys::path::join(result);
53+
if (paths == path) {
54+
return paths;
55+
} else {
56+
std::list<fs::path> result = {path};
57+
58+
auto existing = sys::path::split(paths);
59+
std::copy_if(existing.begin(), existing.end(),
60+
std::back_inserter(result),
61+
[&path](auto current) { return current != path; }
62+
);
63+
64+
return sys::path::join(result);
65+
}
6266
}
6367

6468
std::string Session::remove_from_path(const std::string& path, const std::string& paths)

0 commit comments

Comments
 (0)