n-api: improve performance creating strings · nodejs/node@8e7204e · GitHub
Skip to content

Commit 8e7204e

Browse files
anthony-tuiningaBridgeAR
authored andcommitted
n-api: improve performance creating strings
Improve performance creating strings using N-API by ensuring that the strings are not internalized. Added test cases for latin-1 and utf-16 strings. PR-URL: #26439 Fixes: #26437 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent bf7a52b commit 8e7204e

3 files changed

Lines changed: 55 additions & 6 deletions

File tree

src/js_native_api_v8.cc

Lines changed: 19 additions & 6 deletions

test/js-native-api/test_string/test.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,11 @@ assert.strictEqual(test_string.Utf8Length(str6), 14);
7373
assert.throws(() => {
7474
test_string.TestLargeUtf8();
7575
}, /^Error: Invalid argument$/);
76+
77+
assert.throws(() => {
78+
test_string.TestLargeLatin1();
79+
}, /^Error: Invalid argument$/);
80+
81+
assert.throws(() => {
82+
test_string.TestLargeUtf16();
83+
}, /^Error: Invalid argument$/);

test/js-native-api/test_string/test_string.c

Lines changed: 28 additions & 0 deletions

0 commit comments

Comments
 (0)