josdejong / svelte-jsoneditor

A web-based tool to view, edit, format, repair, query, transform, and validate JSON
https://jsoneditoronline.org
Other
816 stars 108 forks source link

Improve color recognition performance #378

Closed AlexRMU closed 6 months ago

AlexRMU commented 6 months ago
josdejong commented 6 months ago

Are there currently colors that are not recognized, or values that are wrongly recognized as a color? Can you give a couple of examples?

AlexRMU commented 6 months ago

It's more about performance

josdejong commented 6 months ago

Is color recognition a performance bottleneck? If so I'm open to explore better alternatives for the isColor function used right now, but otherwise let's close this issue.

AlexRMU commented 6 months ago

No, it doesn't seem to be

josdejong commented 6 months ago

👍

josdejong commented 5 months ago

I've done a little experiment. When having a JSON document with a very large text, something like 100e6 bytes, it can take about half a second to determine whether it is a color. So I added a check for long text strings, see b1a04fc. I've also applied your idea to reuse the div to test whether some string is a color, see 514f6ca. It seems to improve the performance a bit.

josdejong commented 5 months ago

Improvements are published now in v0.21.2.

AlexRMU commented 5 months ago

👍