Skip to content

Commit 579e952

Browse files
committed
Refactor code to improve AQ operations calling into JS functions
1 parent 183b9be commit 579e952

File tree

3 files changed

+10
-13
lines changed

3 files changed

+10
-13
lines changed

doc/src/release_notes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Thick Mode Changes
6767

6868
#) Internal error handling improvements.
6969

70+
#) Internal code refactoring to optimize JSON data handling.
71+
7072
node-oracledb `v6.7.1 <https://github.com/oracle/node-oracledb/compare/v6.7.0...v6.7.1>`__ (23 Dec 2024)
7173
---------------------------------------------------------------------------------------------------------
7274

src/njsAqQueue.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019, 2024, Oracle and/or its affiliates.
1+
// Copyright (c) 2019, 2025, Oracle and/or its affiliates.
22

33
//-----------------------------------------------------------------------------
44
//
@@ -109,7 +109,7 @@ bool njsAqQueue_setRecipients(njsBaton *baton, dpiMsgProps *handle,
109109
static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
110110
napi_env env, napi_value value, dpiMsgProps **handle)
111111
{
112-
napi_value payloadObj, constructor, tempObj;
112+
napi_value payloadObj, tempObj;
113113
dpiMsgProps *tempHandle;
114114
bool isDbObject;
115115
size_t bufferLength;
@@ -133,10 +133,8 @@ static bool njsAqQueue_createMessage(njsBaton *baton, njsAqQueue *queue,
133133
// set payload
134134
NJS_CHECK_NAPI(env, napi_get_named_property(env, value, "payload",
135135
&payloadObj))
136-
NJS_CHECK_NAPI(env, napi_get_reference_value(env,
137-
baton->globals->jsDbObjectConstructor, &constructor))
138-
NJS_CHECK_NAPI(env, napi_instanceof(env, payloadObj, constructor,
139-
&isDbObject))
136+
NJS_CHECK_NAPI(env, napi_instanceof(env, payloadObj,
137+
baton->jsDbObjectConstructor, &isDbObject))
140138
if (isDbObject) {
141139
// DB Object
142140
if (!njsDbObject_getInstance(baton->globals, env, payloadObj, &obj))
@@ -413,6 +411,9 @@ NJS_NAPI_METHOD_IMPL_ASYNC(njsAqQueue_enq, 1, NULL)
413411
baton->msgProps = calloc(baton->numMsgProps, sizeof(dpiMsgProps*));
414412
if (!baton->msgProps)
415413
return njsBaton_setErrorInsufficientMemory(baton);
414+
415+
if (!njsBaton_setJsValues(baton, env))
416+
return false;
416417
for (i = 0; i < baton->numMsgProps; i++) {
417418
NJS_CHECK_NAPI(env, napi_get_element(env, args[0], i, &message))
418419
if (!njsAqQueue_createMessage(baton, queue, env, message,

src/njsJsonBuffer.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ static bool njsJsonBuffer_populateNode(njsJsonBuffer *buf, dpiJsonNode *node,
142142
{
143143
napi_value temp, name, fieldNames, fieldValues, vectorVal, global;
144144
napi_value uint8Val, uint8Proto, valProto;
145-
napi_value jsSparseConstructor;
146145
napi_valuetype valueType;
147146
napi_typedarray_type type;
148147
size_t tempBufferLength;
@@ -224,13 +223,8 @@ static bool njsJsonBuffer_populateNode(njsJsonBuffer *buf, dpiJsonNode *node,
224223

225224
// handle vectors
226225
NJS_CHECK_NAPI(env, napi_is_typedarray(env, value, &isTyped))
227-
228-
// get the reference from baton->globals as JSON payload in AQ
229-
// does not set inside baton.
230-
NJS_CHECK_NAPI(env, napi_get_reference_value(env,
231-
baton->globals->jsSparseVectorConstructor, &jsSparseConstructor))
232226
NJS_CHECK_NAPI(env, napi_instanceof(env, value,
233-
jsSparseConstructor, &isSparse))
227+
baton->jsSparseVectorConstructor, &isSparse))
234228
if (isTyped || isSparse) { // typed array or sparse vector
235229
NJS_CHECK_NAPI(env, napi_get_global(env, &global))
236230
if (!isSparse) {

0 commit comments

Comments
 (0)