Skip to content

Commit e7f9eef

Browse files
committed
perf(linter/jsplugins): lazy deserialize comments array
1 parent c69201c commit e7f9eef

File tree

1 file changed

+7
-1
lines changed
  • crates/oxc_ast/src/serialize

1 file changed

+7
-1
lines changed

crates/oxc_ast/src/serialize/mod.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,13 @@ impl Program<'_> {
129129
body: null,
130130
sourceType: DESER[ModuleKind](POS_OFFSET.source_type.module_kind),
131131
hashbang: null,
132-
...(COMMENTS && { comments: DESER[Vec<Comment>](POS_OFFSET.comments) }),
132+
...(COMMENTS && {
133+
get comments() {
134+
const c = DESER[Vec<Comment>](POS_OFFSET.comments);
135+
Object.defineProperty(this, 'comments', { value: c });
136+
return c;
137+
}
138+
}),
133139
start,
134140
end,
135141
...(RANGE && { range: [start, end] }),

0 commit comments

Comments
 (0)