mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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 in640a7918
, however, since413c16e4
, no string splitting occurs anymore. Therefore, we can simply pass around some references instead of using string_view or copying strings. Refs: https://github.com/nodejs/node/pull/48491 Refs: https://github.com/nodejs/node/pull/49047 PR-URL: https://github.com/nodejs/node/pull/50662 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
This commit is contained in:
parent
2059913f31
commit
48f32d71a5
@ -119,10 +119,8 @@ namespace permission {
|
||||
// allow = '/tmp/,/home/example.js'
|
||||
void FSPermission::Apply(const std::vector<std::string>& allow,
|
||||
PermissionScope scope) {
|
||||
using std::string_view_literals::operator""sv;
|
||||
|
||||
for (const std::string_view res : allow) {
|
||||
if (res == "*"sv) {
|
||||
for (const std::string& res : allow) {
|
||||
if (res == "*") {
|
||||
if (scope == PermissionScope::kFileSystemRead) {
|
||||
deny_all_in_ = false;
|
||||
allow_all_in_ = true;
|
||||
@ -132,7 +130,7 @@ void FSPermission::Apply(const std::vector<std::string>& allow,
|
||||
}
|
||||
return;
|
||||
}
|
||||
GrantAccess(scope, std::string(res.data(), res.size()));
|
||||
GrantAccess(scope, res);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user