Repository navigation
Commit bd07af4
committed
Do the per-key work of array shapes once per shared value type
Writing through a union offset gives an array shape one optional key per
member of the offset, all holding the same value type. With 250 keys and
a 250-member value type, every operation that walked the keys did the
same work 250 times:
- mergeWith() and legacyMergeWith() unioned each pair of value types once
per key; they now union each distinct pair once, so the merged keys
keep sharing one value type
- isSuperTypeOf() against another shape called getOffsetValueType() and
isSuperTypeOf() once per key; it now compares each pair of value types
once
- countConstantArrayValueTypes() traversed a shared value type once per
key; it now traverses it once and counts it per occurrence
- reduceArrays()' single-constant-scalar lookup inspected the shared
value type once per key
- getValuesArray() and getKeysArray() unioned every window of possible
source values from scratch, quadratic in the number of keys; the window
unions are now kept as a two-stack queue, linear in the number of keys
The inferred types do not change. The turbo-ext mirrors get the same
changes.
Amp-Thread-ID: https://ampcode.com/threads/T-01a1b24f-e4cc-7457-9324-5d29caf3c4811 parent 26e6270 commit bd07af4
6 files changed
Lines changed: 559 additions & 45 deletions
File tree
- src/Type
- Constant
- tests
- PHPStan/Analyser/nsrt
- bench/data
- turbo-ext/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
| 812 | + | |
812 | 813 | | |
813 | 814 | | |
814 | 815 | | |
| |||
831 | 832 | | |
832 | 833 | | |
833 | 834 | | |
834 | | - | |
835 | | - | |
836 | | - | |
837 | | - | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
838 | 854 | | |
839 | | - | |
840 | 855 | | |
841 | 856 | | |
842 | 857 | | |
| |||
2579 | 2594 | | |
2580 | 2595 | | |
2581 | 2596 | | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
2582 | 2609 | | |
2583 | 2610 | | |
2584 | 2611 | | |
| |||
2592 | 2619 | | |
2593 | 2620 | | |
2594 | 2621 | | |
2595 | | - | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
2596 | 2642 | | |
2597 | 2643 | | |
2598 | 2644 | | |
| |||
3155 | 3201 | | |
3156 | 3202 | | |
3157 | 3203 | | |
| 3204 | + | |
| 3205 | + | |
| 3206 | + | |
| 3207 | + | |
3158 | 3208 | | |
3159 | 3209 | | |
3160 | 3210 | | |
| |||
3164 | 3214 | | |
3165 | 3215 | | |
3166 | 3216 | | |
3167 | | - | |
| 3217 | + | |
3168 | 3218 | | |
3169 | 3219 | | |
3170 | 3220 | | |
| |||
3238 | 3288 | | |
3239 | 3289 | | |
3240 | 3290 | | |
| 3291 | + | |
| 3292 | + | |
3241 | 3293 | | |
3242 | 3294 | | |
3243 | 3295 | | |
| |||
3248 | 3300 | | |
3249 | 3301 | | |
3250 | 3302 | | |
3251 | | - | |
| 3303 | + | |
3252 | 3304 | | |
3253 | 3305 | | |
3254 | 3306 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1685 | 1685 | | |
1686 | 1686 | | |
1687 | 1687 | | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
1688 | 1693 | | |
1689 | | - | |
| 1694 | + | |
| 1695 | + | |
| 1696 | + | |
| 1697 | + | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
1690 | 1702 | | |
1691 | 1703 | | |
1692 | 1704 | | |
1693 | 1705 | | |
1694 | | - | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
1695 | 1710 | | |
1696 | 1711 | | |
1697 | 1712 | | |
| |||
1713 | 1728 | | |
1714 | 1729 | | |
1715 | 1730 | | |
| 1731 | + | |
| 1732 | + | |
1716 | 1733 | | |
1717 | | - | |
1718 | | - | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
| 1740 | + | |
| 1741 | + | |
| 1742 | + | |
1719 | 1743 | | |
1720 | | - | |
1721 | | - | |
| 1744 | + | |
1722 | 1745 | | |
1723 | 1746 | | |
1724 | | - | |
| 1747 | + | |
1725 | 1748 | | |
1726 | 1749 | | |
1727 | 1750 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
| |||
0 commit comments