From bfa662eadf4bcc9419abe68631dc6a105c3b6f52 Mon Sep 17 00:00:00 2001 From: William Carroll Date: Fri, 20 Jan 2023 10:31:34 -0800 Subject: feat(wpcarro/slx): Include naive optimizations Empty queries and empty lists. Change-Id: Iacd429feb9d6a0b48ffcac682c3dbd4a0a164134 Reviewed-on: https://cl.tvl.fyi/c/depot/+/7880 Tested-by: BuildkiteCI Autosubmit: wpcarro Reviewed-by: wpcarro --- users/wpcarro/slx.js/index.js | 5 +++++ 1 file changed, 5 insertions(+) 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); } -- cgit 1.4.1