Commit 3683af6
committed
Speed up byteain by not parsing traditional-style input twice.
Instead of laboriously computing the exact output length, use strlen to get an upper bound cheaply. (This is still O(N) of course, but the constant factor is a lot less.) This will typically result in overallocating the output datum, but that's of little concern since it's a short-lived allocation in just about all use-cases. A simple microbenchmark showed about 40% speedup for long input strings. While here, make some cosmetic cleanups and add a test case that covers the double-backslash code path in byteain and byteaout. Author: Steven Niu <niushiji@gmail.com> Reviewed-by: Kirill Reshke <reshkekirill@gmail.com> Reviewed-by: Stepan Neretin <slpmcf@gmail.com> Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/ca315729-140b-426e-81a6-6cd5cfe7ecc5@gmail.com1 parent 84409ed commit 3683af6
File tree
3 files changed
+30
-45
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+30
-45
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
182 | 182 | | |
183 | 183 | | |
184 | 184 | | |
185 | | - | |
186 | | - | |
187 | | - | |
188 | | - | |
189 | | - | |
190 | 185 | | |
191 | 186 | | |
192 | 187 | | |
193 | 188 | | |
194 | 189 | | |
195 | 190 | | |
| 191 | + | |
| 192 | + | |
196 | 193 | | |
197 | 194 | | |
198 | | - | |
199 | 195 | | |
200 | 196 | | |
201 | 197 | | |
202 | 198 | | |
203 | 199 | | |
204 | | - | |
205 | | - | |
206 | 200 | | |
207 | 201 | | |
208 | 202 | | |
| |||
213 | 207 | | |
214 | 208 | | |
215 | 209 | | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
| 210 | + | |
243 | 211 | | |
244 | 212 | | |
245 | 213 | | |
246 | 214 | | |
247 | 215 | | |
248 | 216 | | |
249 | 217 | | |
250 | | - | |
251 | | - | |
| 218 | + | |
252 | 219 | | |
253 | 220 | | |
254 | 221 | | |
255 | | - | |
256 | | - | |
257 | | - | |
258 | | - | |
259 | | - | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
260 | 229 | | |
261 | 230 | | |
262 | 231 | | |
263 | | - | |
264 | | - | |
| 232 | + | |
265 | 233 | | |
266 | 234 | | |
267 | 235 | | |
268 | 236 | | |
269 | 237 | | |
270 | 238 | | |
271 | 239 | | |
272 | | - | |
| 240 | + | |
273 | 241 | | |
274 | 242 | | |
275 | 243 | | |
276 | 244 | | |
277 | 245 | | |
278 | 246 | | |
279 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
280 | 251 | | |
281 | 252 | | |
282 | 253 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
239 | 245 | | |
240 | 246 | | |
241 | 247 | | |
| |||
291 | 297 | | |
292 | 298 | | |
293 | 299 | | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
294 | 306 | | |
295 | 307 | | |
296 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| 92 | + | |
91 | 93 | | |
92 | 94 | | |
93 | 95 | | |
| |||
0 commit comments