Skip to content

Warn on calling .contains() on Lists (for performance)? #58618

@DanTup

Description

@DanTup

While profiling a script in package:win32 I noticed a large amount of time was spent in contains() on a const List. Switching it to a const Set shaved off around 10% of the entire runtime of the script:

halildurmus/win32#337

The question came up of whether the compiler/runtime could be smarter about it (eg. detect contains() on Lists and do some magic behind the scenes to make it a lookup). I'm not sure if that's feasible (although if it is, that may be better) so wondered if a lint may make sense.

I'm not certain if it would end up producing a lot of false positives (or just reports where the savings are so small that they're not worth the error to report/fix), or exactly what situations would make sense to warn, but I thought it my be worth raising for opinions at least.

Metadata

Metadata

Assignees

No one assigned

    Labels

    devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.type-enhancementA request for a change that isn't a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions