#26 Cache data validator functions (globally)

باز‌کردن
2 سال پیش باز شده توسط towerofnix · 0 دیدگاه

According to decorateTime results, the validator returned by validateArrayItems gets called just short of 40,000 times, coming to a total of 2340 ms(!) purely in post-processing (linking wiki data arrays). We can avoid just about all of that, and probably gain performance elsewhere, by caching validator functions.

Note that we might want to do this on a per-validator basis, since it's probably actually faster to just do typeof value === 'number' in primitive checks like isNumber (for example), and it'll be easier to implement per-validator anyway.

According to `decorateTime` results, the validator returned by `validateArrayItems` gets called just short of 40,000 times, coming to a total of 2340 ms(!) purely in post-processing (linking wiki data arrays). We can avoid just about all of that, and probably gain performance elsewhere, by caching validator functions. Note that we might want to do this on a per-validator basis, since it's probably actually faster to just do `typeof value === 'number'` in primitive checks like `isNumber` (for example), and it'll be easier to implement per-validator anyway.
برای پیوستن به گفتگو، وارد شودید.
بدون نقطه عطف
بدون مسئول رسیدگی
1 مشارکت کننده
درحال بارگذاری...
لغو
ذخيره
هنوز محتوایی ایجاد نشده.