diff options
author | William Carroll <wpcarro@gmail.com> | 2023-01-20T18·31-0800 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-20T18·34+0000 |
commit | bfa662eadf4bcc9419abe68631dc6a105c3b6f52 (patch) | |
tree | 300b0c7ab6c150645f32d32fe603fa3bcb48566a | |
parent | f91785bcc2efea5a560acddcbf4ce0d91c27e850 (diff) |
feat(wpcarro/slx): Include naive optimizations r/5712
Empty queries and empty lists. Change-Id: Iacd429feb9d6a0b48ffcac682c3dbd4a0a164134 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7880 Tested-by: BuildkiteCI Autosubmit: wpcarro <wpcarro@gmail.com> Reviewed-by: wpcarro <wpcarro@gmail.com>
-rw-r--r-- | users/wpcarro/slx.js/index.js | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/users/wpcarro/slx.js/index.js b/users/wpcarro/slx.js/index.js index 0f980c8d5a97..8f6eff3c43bd 100644 --- a/users/wpcarro/slx.js/index.js +++ b/users/wpcarro/slx.js/index.js @@ -1,4 +1,9 @@ function select(query, xs, config) { + // naive optimizations + if (query === '' || xs === []) { + return xs; + } + const predicate = compile(parse(query, config), config); return xs.filter(predicate); } |