Skip to content

Inline Stringifier.rawValue for the common case in decl and rule hot paths #69

@alanzabihi

Description

@alanzabihi

Hypothesis

Thesis #54 (accepted) showed that caching node.raws in Stringifier methods gave a 5.2ms improvement. This follow-up thesis pushes further by inlining the rawValue() method call itself in the hottest paths.

rawValue(node, exp, str) (stringifier.js) checks node.raws[exp], then falls back to node[str]. For declarations, rawValue is called twice per node (for between and value). Each call involves: function call overhead, property lookup, conditional check, potential rawCache walk.

Inline the fast path directly in decl():

decl(node, semicolon) {
  let raws = node.raws
  let between = raws.between || ': '  // inline rawValue for 'between'/'colon'
  let value = raws.value !== undefined ? raws.value.value : node.value  // inline rawValue for 'value'
  // ... rest of method
}

Similarly inline in rule() for selector rawValue.

Editable surface

  • lib/stringifier.js — inline rawValue in decl() and rule() hot paths

What's different from prior work

Expected impact

METRIC_A improvement of 1-2ms. METRIC_B improvement of 2-4ms. Combined 2-4ms composite on top of #54's gains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions