Skip to content

Commit

Permalink
perf: add COUNTING_OPS_INDEX for O(1) lookup (#7744)
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz authored Oct 8, 2021
1 parent 36f29c7 commit a45b023
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/aggregate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ export function isAggregateOp(a: string | ArgminDef | ArgmaxDef): a is Aggregate
}

export const COUNTING_OPS: NonArgAggregateOp[] = ['count', 'valid', 'missing', 'distinct'];
export const COUNTING_OPS_INDEX = toSet(COUNTING_OPS);

export function isCountingAggregateOp(aggregate?: string | Aggregate): boolean {
return isString(aggregate) && contains(COUNTING_OPS, aggregate);
return isString(aggregate) && COUNTING_OPS_INDEX[aggregate];
}

export function isMinMaxOp(aggregate?: Aggregate | string): boolean {
Expand Down

0 comments on commit a45b023

Please sign in to comment.