Skip to content

Hoist visitor-independent parse setup out of per-file LazyResult constructor #65

@alanzabihi

Description

@alanzabihi

Hypothesis

In Workload B, each of the 250 files creates a new LazyResult (lazy-result.js constructor). The constructor performs several steps that are identical across all files when using the same Processor: plugin normalization, Result construction, helpers object assembly, warning/message array creation.

Move per-Processor setup to a lazy-initialized cache on Processor:

  1. Normalize plugins once on Processor, not per LazyResult
  2. Create the helpers object template once, clone for each file
  3. Pre-compute the plugin type checks (object vs function) once

The LazyResult constructor then only does per-file work: set the CSS string, root node, opts, and shallow-clone the cached helpers.

Editable surface

  • lib/lazy-result.js — slim down constructor, use cached Processor data
  • lib/processor.js — add lazy-init caches for normalized plugins and helpers template

What's different from prior work

Expected impact

METRIC_B improvement of 3-5ms from eliminating redundant per-file constructor work across 250 files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions