Skip to content

Conversation

bnoordhuis
Copy link
Contributor

Fixes: #482

Copy link
Contributor

@saghul saghul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

goto fail;
if (bc_get_leb128(s, &prop_count))
goto fail;
for(i = 0; i < prop_count; i++) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for(i = 0; i < prop_count; i++) {
for (i = 0; i < prop_count; i++) {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm merely following the predominant style for for loops here (of the 533 for statements in quickjs.c, 66.8% are written this way.)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fabrice and i differ on this, I always put a space after if, for, while, switch, return with a value etc. Fabrice is less adamant about it :)

JS_FreeValue(ctx, rv);
JS_FreeValue(ctx, argv[0]);
JS_FreeValue(ctx, argv[1]);
argv[0] = JS_UNDEFINED;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this necessary since yoy are about to return?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, because it's inside a loop, otherwise we can end up double-freeing argv[1] on the next iteration.

(And I'm clearing argv[0] for clarity's sake, otherwise a casual reader will stop and think: "Why one and not the other?")

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!

@bnoordhuis bnoordhuis merged commit 3a58376 into quickjs-ng:master Aug 19, 2024
@bnoordhuis bnoordhuis deleted the fix482 branch August 19, 2024 10:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JS_WriteObject should support Map and Set

3 participants