Commits
Click on a commit to change the comparison rangeKCL: Faster recasting of arrays
Before this PR, array expression recasting was a bit slow. The reason was that there's two ways to recast an array:
- Single line array string (all items on one line)
- Multi-line array string (n lines, one per item)
The steps were basically:
1. Recast each item, collecting into a vec with n strings (one string per item)
2. Concat the items into a single-line array string
3. If the line is too long, discard it and do a multi-line array string.
Giving each item its own string meant we were doing N allocations (one per item) but it meant that each item was only recast once.
This PR has a better approach. We build a single-line array first, and if it's too long, then ignore it and do a multi-line array. HOWEVER, the difference is that we track each item's offset within the single-line array string. If we then need to convert it into a multi-line array string, we can do that easily by looking up each item's offset.
Improves benchmarks by 7% and 20% on my macbook pro.22 days ago
by adamchalmers