From d57ab2f088a8d41f0899dfe930cca32a03419474 Mon Sep 17 00:00:00 2001 From: Boshen Date: Tue, 21 Feb 2023 12:30:03 +0800 Subject: [PATCH] refactor(ast,parser): remove Node::ctx This is adding too many bytes to the AST --- crates/oxc_ast/src/node.rs | 8 +++----- crates/oxc_parser/src/cursor.rs | 2 +- crates/oxc_parser/src/lib.rs | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/oxc_ast/src/node.rs b/crates/oxc_ast/src/node.rs index 821622d9a..eebb26883 100644 --- a/crates/oxc_ast/src/node.rs +++ b/crates/oxc_ast/src/node.rs @@ -6,7 +6,7 @@ use std::{ use serde::Serialize; #[allow(clippy::wildcard_imports)] -use crate::{ast::*, context::Context}; +use crate::ast::*; pub type Span = Range; @@ -14,15 +14,13 @@ pub type Span = Range; pub struct Node { pub start: usize, pub end: usize, - #[serde(skip)] - pub ctx: Context, } impl Node { #[must_use] #[inline] - pub const fn new(start: usize, end: usize, ctx: Context) -> Self { - Self { start, end, ctx } + pub const fn new(start: usize, end: usize) -> Self { + Self { start, end } } #[must_use] diff --git a/crates/oxc_parser/src/cursor.rs b/crates/oxc_parser/src/cursor.rs index a33c70816..7d1904031 100644 --- a/crates/oxc_parser/src/cursor.rs +++ b/crates/oxc_parser/src/cursor.rs @@ -17,7 +17,7 @@ impl<'a> Parser<'a> { #[must_use] pub const fn start_node(&self) -> Node { let token = self.cur_token(); - Node::new(token.start, 0, self.ctx) + Node::new(token.start, 0) } #[must_use] diff --git a/crates/oxc_parser/src/lib.rs b/crates/oxc_parser/src/lib.rs index 74a489286..180595868 100644 --- a/crates/oxc_parser/src/lib.rs +++ b/crates/oxc_parser/src/lib.rs @@ -109,7 +109,7 @@ impl<'a> Parser<'a> { let (directives, statements) = self.parse_directives_and_statements(/* is_top_level */ true)?; - let node = Node::new(0, self.source.len(), self.ctx); + let node = Node::new(0, self.source.len()); Ok(self.ast.program(node, directives, statements, self.source_type)) }