perf(linter): avoid operator allocations in no-useless-length-check (#28471)

Use static slices for the fixed operator sets instead of allocating two
vectors for every candidate expression pair.

Co-authored-by: Copilot

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2026-10-30 12:26:30 -04:00
1 parent 004647a4fa
commit 6f3e982b81
1 file changed
+5 -5
@@ -67,9 +67,9 @@ declare_oxc_lint!(
short_description = "Disallow useless array length check.",
);
struct ConditionDTO<T: ToString> {
property_name: T,
binary_operators: Vec<BinaryOperator>,
struct ConditionDTO {
property_name: &'static str,
binary_operators: &'static [BinaryOperator],
}
fn is_useless_check<'a>(
@@ -79,11 +79,11 @@ fn is_useless_check<'a>(
) -> Option<OxcDiagnostic> {
let every_condition = ConditionDTO {
property_name: "every",
binary_operators: vec![BinaryOperator::StrictEquality],
binary_operators: &[BinaryOperator::StrictEquality],
};
let some_condition = ConditionDTO {
property_name: "some",
binary_operators: vec![BinaryOperator::StrictInequality, BinaryOperator::GreaterThan],
binary_operators: &[BinaryOperator::StrictInequality, BinaryOperator::GreaterThan],
};
let mut array_name: &str = "";