Skip to content

perf: resolve tag names only when sanitizeName is set - #37

Open
g4lb wants to merge 1 commit into
NaturalIntelligence:mainfrom
g4lb:perf-sanitize-name-guard
Open

g4lb wants to merge 1 commit into
NaturalIntelligence:mainfrom
g4lb:perf-sanitize-name-guard

Conversation

@g4lb

@g4lb g4lb commented Nov 24, 2026

Copy link
Copy Markdown

j2x() now calls resolveName() only if the options have sanitizeName. Without sanitizeName, resolveName() returns the key unchanged. The output does not change.

Input Before After Change
500 rows with 6 fields 1.17 ms 1.04 ms -11.0%
500 rows with attributes 1.11 ms 1.03 ms -7.1%
40 levels of nested objects, format: true 56.8 µs 52.3 µs -7.8%
Numbers, booleans, null, Date and arrays 9.25 µs 8.21 µs -11.3%

With lib/fxb.cjs, these inputs are 6% to 10% faster. I measured no slowdown with sanitizeName, preserveOrder or entities (15 rounds, Mann-Whitney test, Apple M2 Max, Node 24).

Checks:

  • npm test passes on Node 16, 18, 22 and 24.
  • Old and new outputs matched on 1M random inputs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant