- Notifications
You must be signed in to change notification settings - Fork5k
Commit3683af6
committed
Speed up byteain by not parsing traditional-style input twice.
Instead of laboriously computing the exact output length, use strlento get an upper bound cheaply. (This is still O(N) of course, butthe constant factor is a lot less.) This will typically result inoverallocating the output datum, but that's of little concern sinceit's a short-lived allocation in just about all use-cases.A simple microbenchmark showed about 40% speedup for long inputstrings.While here, make some cosmetic cleanups and add a test case thatcovers 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 parent84409ed commit3683af6
File tree
3 files changed
+30
-45
lines changed- src
- backend/utils/adt
- test/regress
- expected
- sql
3 files changed
+30
-45
lines changedLines changed: 16 additions & 45 deletions
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 |
| |
|
Lines changed: 12 additions & 0 deletions
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 |
| |
|
Lines changed: 2 additions & 0 deletions
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
Comments
(0)