unjs / destr

๐Ÿš€ Faster, secure and convenient alternative for JSON.parse
MIT License
1.03k stars 14 forks source link

perf: avoid lowercasing long strings #81

Closed webstrand closed 11 months ago

webstrand commented 11 months ago

๐Ÿ”— Linked issue

80

โ“ Type of change

๐Ÿ“š Description

If the string is longer than nine characters it cannot possibly match any of the hard-coded strings. So wrap the lowercasing operation in a conditional that prevents the operation if the string is ten characters or longer.

๐Ÿ“ Checklist

pi0 commented 11 months ago

Perf gains are amazing! https://github.com/unjs/destr/commit/eb60af13cba90e26889892b4e9022749e3537b3f