mirror of
https://github.com/oxc-project/oxc.git
synced 2026-11-04 10:29:58 +00:00
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:
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 = "";
|
||||
|
||||
Reference in new issue
Block a user