Commit a1ed2f8
committed
internal/codegen: cache pattern matching compilations
Type overrides are checked linearly for every codegen'd type.
That linear check currently compiles a regexp pattern for every override
that's considered. This commit adds a simple memoizing cache so that
each pattern is only ever compiled once. This dramatically improves
performance of sqlc for users who have many overrides. ngrok's usage
of sqlc generate sees a 10x speedup from this change (4s -> 0.4s).1 parent d64a68b commit a1ed2f8
1 file changed
+20
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | 7 | | |
6 | 8 | | |
| |||
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
16 | 23 | | |
17 | | - | |
18 | | - | |
19 | | - | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
20 | 36 | | |
| 37 | + | |
21 | 38 | | |
22 | 39 | | |
23 | 40 | | |
| |||
0 commit comments