futil-js / contexture-react

React components for building contexture interfaces
https://smartprocure.github.io/contexture-react
MIT License
6 stars 4 forks source link

Improve Field Picker Search Performance #535

Open daedalus28 opened 2 years ago

daedalus28 commented 2 years ago

https://github.com/smartprocure/contexture-react/blob/53127ed0058ab4028593f2c81177ce66c39c8d49/src/greyVest/NestedPicker.js#L144

Can be changed to

let matchLabel = str => {
  let match = F.matchAllWords(str)
  return _.filter(x => match(x.label))
}

This will avoid recreating the regex on every iteration. Not sure if this is the bottleneck, but it's an easy performance win.