Commit 9d4d68a
Luca Buzzi
Optimize view rendering with sync.Pool for buffer reuse and improved performance
- introduced a global sync.Pool for reusing *bytes.Buffer instances to reduce GC pressure and improve memory efficiency
- updated Request.View and Request.RenderView to utilize the buffer pool
- ensured proper buffer cleanup with defer and Reset before returning buffers to the pool
- replaced per-view buffer instantiation with pooled buffers and added logic to handle intermediate view rendering
- preserved previous functionality while enhancing performance and reducing memory allocations1 parent 4b2f116 commit 9d4d68a
1 file changed
+42
-19
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
8 | 7 | | |
9 | 8 | | |
10 | 9 | | |
| 10 | + | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
49 | 51 | | |
50 | 52 | | |
51 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
52 | 60 | | |
53 | 61 | | |
54 | 62 | | |
| |||
138 | 146 | | |
139 | 147 | | |
140 | 148 | | |
141 | | - | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
142 | 153 | | |
143 | | - | |
144 | 154 | | |
145 | 155 | | |
146 | 156 | | |
| |||
203 | 213 | | |
204 | 214 | | |
205 | 215 | | |
206 | | - | |
| 216 | + | |
207 | 217 | | |
208 | 218 | | |
209 | 219 | | |
| |||
234 | 244 | | |
235 | 245 | | |
236 | 246 | | |
237 | | - | |
238 | | - | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
239 | 254 | | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
240 | 258 | | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
245 | | - | |
246 | | - | |
247 | | - | |
248 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
249 | 275 | | |
250 | | - | |
251 | 276 | | |
252 | | - | |
253 | | - | |
254 | 277 | | |
255 | 278 | | |
256 | | - | |
257 | | - | |
| 279 | + | |
| 280 | + | |
258 | 281 | | |
259 | 282 | | |
260 | 283 | | |
| |||
0 commit comments