Skip to content

Commit 8883eaf

Browse files
minor improvement
1 parent 1d112b3 commit 8883eaf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/PyBytesProxyHandler.cc

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,8 +287,10 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
287287
if (id.isString()) {
288288
bool isProperty;
289289

290+
JSString *idString = id.toString();
291+
290292
// "length" and "byteLength" properties have the same value
291-
if (((JS_StringEqualsLiteral(cx, id.toString(), "length", &isProperty) && isProperty) || (JS_StringEqualsLiteral(cx, id.toString(), "byteLength", &isProperty) && isProperty))) {
293+
if (((JS_StringEqualsLiteral(cx, idString, "length", &isProperty) && isProperty) || (JS_StringEqualsLiteral(cx, id.toString(), "byteLength", &isProperty) && isProperty))) {
292294
JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
293295

294296
JS::RootedObject rootedArrayBuffer(cx, arrayBuffer->get());
@@ -304,7 +306,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
304306
}
305307

306308
// "buffer" property
307-
if (JS_StringEqualsLiteral(cx, id.toString(), "buffer", &isProperty) && isProperty) {
309+
if (JS_StringEqualsLiteral(cx, idString, "buffer", &isProperty) && isProperty) {
308310
JS::PersistentRootedObject* arrayBuffer = JS::GetMaybePtrFromReservedSlot<JS::PersistentRootedObject>(proxy, OtherSlot);
309311

310312
desc.set(mozilla::Some(
@@ -316,7 +318,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
316318
}
317319

318320
// "BYTES_PER_ELEMENT" property
319-
if (JS_StringEqualsLiteral(cx, id.toString(), "BYTES_PER_ELEMENT", &isProperty) && isProperty) {
321+
if (JS_StringEqualsLiteral(cx, idString, "BYTES_PER_ELEMENT", &isProperty) && isProperty) {
320322
desc.set(mozilla::Some(
321323
JS::PropertyDescriptor::Data(
322324
JS::Int32Value(1)
@@ -326,7 +328,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
326328
}
327329

328330
// "byteOffset" property
329-
if (JS_StringEqualsLiteral(cx, id.toString(), "byteOffset", &isProperty) && isProperty) {
331+
if (JS_StringEqualsLiteral(cx, idString, "byteOffset", &isProperty) && isProperty) {
330332
desc.set(mozilla::Some(
331333
JS::PropertyDescriptor::Data(
332334
JS::Int32Value(0)
@@ -336,7 +338,7 @@ bool PyBytesProxyHandler::getOwnPropertyDescriptor(
336338
}
337339

338340
// "constructor" property
339-
if (JS_StringEqualsLiteral(cx, id.toString(), "constructor", &isProperty) && isProperty) {
341+
if (JS_StringEqualsLiteral(cx, idString, "constructor", &isProperty) && isProperty) {
340342
JS::RootedObject uint8ArrayPrototype(cx);
341343
if (!JS_GetClassPrototype(cx, JSProto_Uint8Array, &uint8ArrayPrototype)) {
342344
return false;

0 commit comments

Comments
 (0)