Skip to content

Commit 0faf06f

Browse files
committed
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
1 parent a00f0b1 commit 0faf06f

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
@@ -118,10 +118,8 @@ namespace permission {
118118
// allow = '/tmp/,/home/example.js'
119119
void FSPermission::Apply(const std::vector<std::string>& allow,
120120
PermissionScope scope) {
121-
using std::string_view_literals::operator""sv;
122-
123-
for (const std::string_view res : allow) {
124-
if (res == "*"sv) {
121+
for (const std::string& res : allow) {
122+
if (res == "*") {
125123
if (scope == PermissionScope::kFileSystemRead) {
126124
deny_all_in_ = false;
127125
allow_all_in_ = true;
@@ -131,7 +129,7 @@ void FSPermission::Apply(const std::vector<std::string>& allow,
131129
}
132130
return;
133131
}
134-
GrantAccess(scope, std::string(res.data(), res.size()));
132+
GrantAccess(scope, res);
135133
}
136134
}
137135

0 commit comments

Comments
 (0)