Commit 36d004a
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 7d3863f commit 36d004a
1 file changed
Lines changed: 26 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 | + | |
| 626 | + | |
621 | 627 | | |
622 | | - | |
623 | | - | |
| 628 | + | |
| 629 | + | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
624 | 633 | | |
625 | | - | |
626 | | - | |
627 | | - | |
628 | | - | |
| 634 | + | |
629 | 635 | | |
630 | 636 | | |
631 | | - | |
| 637 | + | |
632 | 638 | | |
633 | 639 | | |
634 | | - | |
635 | | - | |
636 | | - | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
637 | 644 | | |
638 | 645 | | |
639 | 646 | | |
| |||
0 commit comments