Skip to content

Commit 48f32d7

Browse files
authored
src: avoid copying strings in FSPermission::Apply
The use of string_view and subsequent copying to a string was supposed to be a minor optimization in 640a7918, however, since 413c16e, no string splitting occurs anymore. Therefore, we can simply pass around some references instead of using string_view or copying strings. Refs: #48491 Refs: #49047 PR-URL: #50662 Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 2059913 commit 48f32d7

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/permission/fs_permission.cc

+3-5
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,8 @@ namespace permission {
119119
// allow = '/tmp/,/home/example.js'
120120
void FSPermission::Apply(const std::vector<std::string>& allow,
121121
PermissionScope scope) {
122-
using std::string_view_literals::operator""sv;
123-
124-
for (const std::string_view res : allow) {
125-
if (res == "*"sv) {
122+
for (const std::string& res : allow) {
123+
if (res == "*") {
126124
if (scope == PermissionScope::kFileSystemRead) {
127125
deny_all_in_ = false;
128126
allow_all_in_ = true;
@@ -132,7 +130,7 @@ void FSPermission::Apply(const std::vector<std::string>& allow,
132130
}
133131
return;
134132
}
135-
GrantAccess(scope, std::string(res.data(), res.size()));
133+
GrantAccess(scope, res);
136134
}
137135
}
138136

0 commit comments

Comments
 (0)