forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit9f1ca6c
committed
Use appendStringInfoSpaces in more places
This adjusts a few places which were appending a string constantcontaining spaces onto a StringInfo. We have appendStringInfoSpaces forthat job, so let's use that instead.For the change to jsonb.c's add_indent() function, appendStringInfoStringwas being called inside a loop to append 4 spaces on each loop. Thismeant that enlargeStringInfo would get called once per loop. Here itshould be much more efficient to get rid of the loop and just calculatethe number of spaces with "level * 4" and just append all the spaces inone go.Here we additionally adjust the appendStringInfoSpaces function so itmakes use of memset rather than a while loop to apply the required spacesto the StringInfo. One of the problems with the while loop was that itwas incrementing one variable and decrementing another variable once perloop. That's more work than what's required to get the job done. We mayas well use memset for this rather than trying to optimize the existingloop. Some testing has shown memset is faster even for very small sizes.Discussion:https://postgr.es/m/CAApHDvp_rKkvwudBKgBHniNRg67bzXVjyvVKfX0G2zS967K43A@mail.gmail.com1 parent1ca604c commit9f1ca6c
File tree
3 files changed
+4
-7
lines changed- src
- backend
- commands
- utils/adt
- common
3 files changed
+4
-7
lines changedLines changed: 1 addition & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3324 | 3324 |
| |
3325 | 3325 |
| |
3326 | 3326 |
| |
3327 |
| - | |
| 3327 | + | |
3328 | 3328 |
| |
3329 | 3329 |
| |
3330 | 3330 |
| |
|
Lines changed: 1 addition & 4 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
626 | 626 |
| |
627 | 627 |
| |
628 | 628 |
| |
629 |
| - | |
630 |
| - | |
631 | 629 |
| |
632 |
| - | |
633 |
| - | |
| 630 | + | |
634 | 631 |
| |
635 | 632 |
| |
636 | 633 |
| |
|
Lines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
211 | 211 |
| |
212 | 212 |
| |
213 | 213 |
| |
214 |
| - | |
215 |
| - | |
| 214 | + | |
| 215 | + | |
216 | 216 |
| |
217 | 217 |
| |
218 | 218 |
| |
|
0 commit comments
Comments
(0)