summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorEvan Welsh <contact@evanwelsh.com>2022-07-22 10:40:34 -0700
committerPhilip Chimento <philip.chimento@gmail.com>2022-08-06 14:13:58 -0700
commita987fee778641e1cbac1e02112065fb04a3dbad8 (patch)
tree3fc67358a33c2d053f5d23f49fa910ff4eff838d /modules
parent0ebe34f8a59824aba6ca362a18777a193d766a36 (diff)
downloadgjs-a987fee778641e1cbac1e02112065fb04a3dbad8.tar.gz
js: Use length overload of JS::NewArrayObject()
It's not necessary to use JS::HandleValueArray::empty() here, since we can just create an empty array of the proper length using the overload that lets you specify an integer length.
Diffstat (limited to 'modules')
-rw-r--r--modules/cairo-context.cpp13
1 files changed, 3 insertions, 10 deletions
diff --git a/modules/cairo-context.cpp b/modules/cairo-context.cpp
index 463e0621..e321a6f2 100644
--- a/modules/cairo-context.cpp
+++ b/modules/cairo-context.cpp
@@ -20,7 +20,6 @@
#include <js/TypeDecls.h>
#include <js/Utility.h> // for UniqueChars
#include <js/Value.h>
-#include <js/ValueArray.h>
#include <jsapi.h> // for JS_SetElement
#include "gi/arg-inl.h"
@@ -86,9 +85,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
return false; \
cfunc(cr, &arg1, &arg2); \
if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) { \
- JS::RootedObject array( \
- context, \
- JS::NewArrayObject(context, JS::HandleValueArray::empty())); \
+ JS::RootedObject array(context, JS::NewArrayObject(context, 2)); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \
@@ -107,9 +104,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
_GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
cfunc(cr, &arg1, &arg2); \
if (cairo_status(cr) == CAIRO_STATUS_SUCCESS) { \
- JS::RootedObject array( \
- context, \
- JS::NewArrayObject(context, JS::HandleValueArray::empty())); \
+ JS::RootedObject array(context, JS::NewArrayObject(context, 2)); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \
@@ -128,9 +123,7 @@ _GJS_CAIRO_CONTEXT_DEFINE_FUNC_END
_GJS_CAIRO_CONTEXT_CHECK_NO_ARGS(method) \
cfunc(cr, &arg1, &arg2, &arg3, &arg4); \
{ \
- JS::RootedObject array( \
- context, \
- JS::NewArrayObject(context, JS::HandleValueArray::empty())); \
+ JS::RootedObject array(context, JS::NewArrayObject(context, 4)); \
if (!array) \
return false; \
JS::RootedValue r(context, JS::NumberValue(arg1)); \