Semantic Diff

#9267 Drop the Flow parser's comment-moving AST mapper classes

1 commit

98faffcf7247f40c91dde2c5eca2732b579d6468..pr-9267

defd652ed · cknitt + Claude · Nov 08, 2026, 18:03 UTC

Drop the Flow parser's comment-moving AST mapper classes

Flow moves trailing comments off nodes it has already built with an AST mapper class (Flow_ast_mapper, 336 methods) and two subclasses in Comment_attachment. OCaml creates classes when their module is initialized, so every compiler process built their method tables: about 206,000 of the compiler's ~275,000 startup words, although ReScript only parses %raw code with the Flow parser and never reads trailing comments (only the leading comment of a %raw literal, which the parser collects without the mapper).

The removers now return the node unchanged; what they kept is the consumption of comments, which decides where later comments attach. Flow_ast_mapper and both classes go. The Flow parser's startup allocation, measured by linking it into an otherwise empty program, drops from 227,172 to 20,669 words.