#26 Cache data validator functions (globally)

开启中
towerofnix2 年之前创建 · 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 名参与者
正在加载...
取消
保存
这个人很懒,什么都没留下。