Commit ee75709
Filter modules during collection in IEx autocomplete
Instead of collecting all modules as strings, sorting the full list, and
then linearly scanning for matching prefixes, filter modules during
collection and only sort the (much smaller) set of matches.
Benchmarked with 261 loaded modules, compared against the original code
(before the previous two optimizations) and the current code:
match_modules("Elixir.Enum"):
before PR: 333 µs, 13.6 KB heap
current: 91 µs, 1.6 KB heap
proposed: 30 µs, 0.5 KB heap (11x faster, 26x less heap)
match_modules("er"):
before PR: 345 µs, 13.8 KB heap
current: 97 µs, 2.9 KB heap
proposed: 39 µs, 0.4 KB heap (9x faster, 33x less heap)
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent ae79f84 commit ee75709
1 file changed
Lines changed: 25 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
609 | 609 | | |
610 | 610 | | |
611 | 611 | | |
612 | | - | |
613 | | - | |
614 | | - | |
615 | | - | |
616 | | - | |
617 | | - | |
618 | | - | |
619 | | - | |
620 | | - | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
621 | 626 | | |
622 | | - | |
623 | | - | |
| 627 | + | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
624 | 632 | | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
| 633 | + | |
629 | 634 | | |
630 | 635 | | |
631 | | - | |
| 636 | + | |
632 | 637 | | |
633 | 638 | | |
634 | | - | |
635 | | - | |
636 | | - | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
637 | 643 | | |
638 | 644 | | |
639 | 645 | | |
| |||
0 commit comments