Skip to content

Eliminate the input validation preamble on cache hit #60

@alanzabihi

Description

@alanzabihi

Per #58: cache-hit is the bottleneck. Current hit path likely: typeof str === 'string' check + str.length check + Map.get. Restructure so cache.get happens FIRST, only run validation on miss. Invalid non-string inputs would then miss cache and fall through to validation. Tests expect: ms(null), ms(undefined) return undefined; ms(123) format; ms(new Date()). All via slow-path. Cache only stores valid string->number; misses still validate. Target: 1-3ms reduction on hit path. Fingerprints preserved — behavior identical.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions