digitalbazaar / jsonld.js

A JSON-LD Processor and API implementation in JavaScript
https://json-ld.org/
Other
1.65k stars 195 forks source link

Improve compactIri performance #460

Open Janpot opened 2 years ago

Janpot commented 2 years ago

Having some performance problems on some particularly large input. I noticed this quite costly loop that could be replaced with a Map lookup. Seems to reduce the overall runtime of .compact by about 50%.

for reference, the offending data: https://gist.githubusercontent.com/Janpot/792ae65f50d53a2903ffd87d29bec782/raw/51199036e09c9567ebfa4b04d03f5e207a39cdae/large-jsonld.json encountered on this website: https://www.stanglwirt.com