Skip to content

Commit 615612e

Browse files
committed
permission: reuse cached env strings
Permission::is_scope_granted() and Permission::Drop() built the "permission" and "resource" diagnostics message keys with FIXED_ONE_BYTE_STRING(isolate, ...) on every publish, even though Environment already caches these exact strings via env->permission_string() and env->resource_string() (src/env_properties.h). One call site in the same file already used the cached accessor; these two did not, and Environment is already in scope at both sites. Assisted-by: Claude Sonnet 5 Signed-off-by: agape1225 <49804691+agape1225@users.noreply.github.com>
1 parent b9dacd4 commit 615612e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/permission/permission.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,11 @@ bool Permission::is_scope_granted(Environment* env,
257257
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
258258
const char* perm_str = PermissionToString(permission);
259259
msg->Set(context,
260-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
260+
env->permission_string(),
261261
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
262262
.Check();
263263
msg->Set(context,
264-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
264+
env->resource_string(),
265265
v8::String::NewFromUtf8(isolate,
266266
res.data(),
267267
v8::NewStringType::kNormal,
@@ -327,11 +327,11 @@ void Permission::Drop(Environment* env,
327327
v8::Object::New(isolate, v8::Null(isolate), nullptr, nullptr, 0);
328328
const char* perm_str = PermissionToString(scope);
329329
msg->Set(context,
330-
FIXED_ONE_BYTE_STRING(isolate, "permission"),
330+
env->permission_string(),
331331
v8::String::NewFromUtf8(isolate, perm_str).ToLocalChecked())
332332
.Check();
333333
msg->Set(context,
334-
FIXED_ONE_BYTE_STRING(isolate, "resource"),
334+
env->resource_string(),
335335
v8::String::NewFromUtf8(isolate,
336336
param.data(),
337337
v8::NewStringType::kNormal,

0 commit comments

Comments
 (0)