mirror of
https://github.com/DoneJS-Runtime/quickjs-done-nextgen.git
synced 2025-01-09 17:43:15 +00:00
Optimize js_map_write, don't loop twice (#488)
This commit is contained in:
parent
4e52027fe7
commit
568ac13ff5
1 changed files with 1 additions and 11 deletions
12
quickjs.c
12
quickjs.c
|
@ -46103,18 +46103,8 @@ static int js_map_write(BCWriterState *s, struct JSMapState *map_state,
|
||||||
{
|
{
|
||||||
struct list_head *el;
|
struct list_head *el;
|
||||||
JSMapRecord *mr;
|
JSMapRecord *mr;
|
||||||
uint32_t count;
|
|
||||||
|
|
||||||
count = 0;
|
|
||||||
|
|
||||||
if (map_state) {
|
|
||||||
list_for_each(el, &map_state->records) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bc_put_leb128(s, count);
|
|
||||||
|
|
||||||
|
bc_put_leb128(s, map_state ? map_state->record_count : 0);
|
||||||
if (map_state) {
|
if (map_state) {
|
||||||
list_for_each(el, &map_state->records) {
|
list_for_each(el, &map_state->records) {
|
||||||
mr = list_entry(el, JSMapRecord, link);
|
mr = list_entry(el, JSMapRecord, link);
|
||||||
|
|
Loading…
Reference in a new issue