Commit 18c0ca4
perf(database): skip casting for already-canonical types
casting() was looping over every attribute, building a single-element
array, running a match that fell through to default for strings,
datetimes, JSON, and so on, and then re-storing the value with
setAttribute. That whole round trip is dead work for any attribute
whose type doesn't actually need a PHP-side cast.
Skip the load + setAttribute pair when the type isn't one of id,
boolean, integer, or double (and isn't an array). Per find with N
docs × M attributes this used to allocate N×M tiny arrays and call
setAttribute that many times; the typical schema is mostly strings,
so the win compounds quickly.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 20c9041 commit 18c0ca4
1 file changed
Lines changed: 28 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1683 | 1683 | | |
1684 | 1684 | | |
1685 | 1685 | | |
| 1686 | + | |
| 1687 | + | |
| 1688 | + | |
| 1689 | + | |
| 1690 | + | |
| 1691 | + | |
| 1692 | + | |
| 1693 | + | |
| 1694 | + | |
1686 | 1695 | | |
1687 | 1696 | | |
1688 | 1697 | | |
| 1698 | + | |
| 1699 | + | |
| 1700 | + | |
| 1701 | + | |
1689 | 1702 | | |
1690 | 1703 | | |
1691 | | - | |
1692 | | - | |
| 1704 | + | |
| 1705 | + | |
| 1706 | + | |
| 1707 | + | |
| 1708 | + | |
| 1709 | + | |
| 1710 | + | |
| 1711 | + | |
| 1712 | + | |
| 1713 | + | |
| 1714 | + | |
1693 | 1715 | | |
1694 | 1716 | | |
1695 | 1717 | | |
1696 | | - | |
| 1718 | + | |
| 1719 | + | |
1697 | 1720 | | |
1698 | 1721 | | |
1699 | 1722 | | |
1700 | 1723 | | |
1701 | | - | |
| 1724 | + | |
1702 | 1725 | | |
1703 | | - | |
| 1726 | + | |
1704 | 1727 | | |
1705 | 1728 | | |
1706 | 1729 | | |
| |||
0 commit comments