GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||
GeezerVison is showing github.com — src: migrate to new V8 array API by kt3k · Pull Request #24613 · nodejs/node Conversation
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| int state = promise->State(); | ||
| ret->Set(env->context(), 0, Integer::New(isolate, state)).FromJust(); | ||
| std::vector<Local<Value>> values; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
values(2), as we can have a maximum of two values.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Then way not simply:
| std::vector<Local<Value>> values; | |
| Local<Value> values[2] = { Integer::New(isolate, state) }; | |
| size_t number_of_values = 1; | |
| if (state != Promise::PromiseState::kPending) | |
| values[number_of_values++] = promise->Result(); | |
| DCHECK_LE(number_of_values, arraysize(values)); | |
| Local<Array> ret = Array::New(isolate, values, number_of_values); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
That’s much longer and doesn’t really provide too much of an advantage over using a vector.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
AFAICT it's only one line longer, and we get everything on the stack with no free-store allocations.
I thought that when possible, we prefer static sized data structures?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I tried @refack's suggestion, but I couldn't find a reasonable way to include DCHECK_LE in this file. DCHECK_LE is defined in deps/v8/src/base/logging.h, and when I add #include "../deps/v8/src/base/logging.h" at the top, the compile doesn't seem passing (relative path inside logging.h doesn't seem resolving...)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I followed @TimothyGu's comment for the moment.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
With values(2), the values are initialized with empty values and it has size 2. So I needed to add an else block and .pop_back() the last (empty) value. (I think that's unnecessarily complex and not desirable code.)
So I changed the code to follow @refack's comment (without DCHECK_LE assertion).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This addresses the comment in nodejs#24613
fe987df to
0098eb2
Compare
Use static sized data structure
0098eb2 to
3729328
Compare
|
(I force-pushed with empty change a few times to fix CI status but it keeps failing because of the rate limit of github API, which is used for fetching the commit message.) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Landed in 27139fc |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This change migrates the deprecated V8 Array API to new APIs. PR-URL: nodejs#24613 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
|
Thank you for the reviews! Thank you for landing! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
This change migrates the deprecated V8 Array API to new APIs. PR-URL: #24613 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
This change migrates the deprecated V8 Array API to new APIs. PR-URL: nodejs#24613 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Joyee Cheung <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Gireesh Punathil <[email protected]> Reviewed-By: Gus Caplan <[email protected]> Reviewed-By: Tiancheng "Timothy" Gu <[email protected]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.