Commit 6de22fd
committed
♻️ Coalesce entries in SequenceSet#append
You can build an ordered set from an enumarable input as simply as
`enum.inject(Net::IMAP::SequenceSet.new, &:append)`. But, prior to this
change, that could easily give you very inefficient output, e.g: it
might return `9,1,2,3,4,5,6,7,8`. With this change, the same input will
return `9,1:8`.
This also short-circuits whenever `@string` is `nil`, avoiding string
generation. This significantly improves performance when the set
remains monotonically sorted.1 parent 70218a0 commit 6de22fd
File tree
2 files changed
+52
-4
lines changed- lib/net/imap
- test/net/imap
2 files changed
+52
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
954 | 954 | | |
955 | 955 | | |
956 | 956 | | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
957 | 974 | | |
958 | 975 | | |
959 | 976 | | |
960 | 977 | | |
961 | 978 | | |
962 | 979 | | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
963 | 1000 | | |
964 | | - | |
965 | 1001 | | |
966 | | - | |
| 1002 | + | |
967 | 1003 | | |
968 | 1004 | | |
969 | 1005 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
661 | 661 | | |
662 | 662 | | |
663 | 663 | | |
664 | | - | |
665 | 664 | | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
666 | 678 | | |
667 | 679 | | |
668 | 680 | | |
669 | 681 | | |
670 | 682 | | |
671 | 683 | | |
672 | | - | |
| 684 | + | |
673 | 685 | | |
674 | 686 | | |
675 | 687 | | |
| |||
0 commit comments