perf(schema): optimize convertType with fast paths for compatible types#931
Conversation
Implement fast paths in convertType to avoid expensive slice traversal when types are identical or have compatible underlying types (e.g. json.RawMessage to []byte).
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #931 +/- ##
==========================================
- Coverage 92.62% 92.58% -0.04%
==========================================
Files 23 23
Lines 4499 4503 +4
==========================================
+ Hits 4167 4169 +2
- Misses 274 275 +1
- Partials 58 59 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks so much for this optimization! I spent some time putting tests and benchmarks together (with Claude's help) to compare this versus the original implementation. If you'd like to run the benchmarks yourself, extract this zip and run Unfortunately I noticed that your optimization caused a +32.36% increase for same type vars, but that was easy to remedy :) Here were my results with your original implementation: And here's the slight improvement with my further optimization: Great work! Thanks so much! |
Implement fast paths in convertType to avoid expensive slice traversal when types are identical or have compatible underlying types (e.g.
json.RawMessageto[]byte).