forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commit3ab2668
committed
Use psprintf to simplify gtsvectorout()
The buffer allocation was correct, but looked archaic and scary:- It was weird to calculate the buffer size before determining which format string was used. With the same effort, we could've used the right-sized buffer for each branch.- Commitaa0d350 added one more possible return string ("all true bits"), but didn't adjust the code at the top of the function to calculate the returned string's max size. It was not a live bug, because the new string was smaller than the existing ones, but seemed wrong in principle.- Use of sprintf() is generally eyebrow-raising these daysSwitch to psprintf(). psprintf() allocates a larger buffer than whatwas allocated before, 128 bytes vs 80 bytes, which is acceptable asthis code is not performance or space critical.Reviewed-by: Andres FreundDiscussion:https://www.postgresql.org/message-id/54c29fb0-edf2-48ea-9814-44e918bbd6e8@iki.fi1 parentd5f139c commit3ab2668
1 file changed
+4
-13
lines changedLines changed: 4 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
96 | 96 |
| |
97 | 97 |
| |
98 | 98 |
| |
99 |
| - | |
100 |
| - | |
101 |
| - | |
102 |
| - | |
103 |
| - | |
104 |
| - | |
105 | 99 |
| |
106 | 100 |
| |
107 | 101 |
| |
108 | 102 |
| |
109 | 103 |
| |
110 | 104 |
| |
111 |
| - | |
112 |
| - | |
113 |
| - | |
114 |
| - | |
115 | 105 |
| |
116 |
| - | |
| 106 | + | |
117 | 107 |
| |
118 | 108 |
| |
119 | 109 |
| |
120 |
| - | |
| 110 | + | |
121 | 111 |
| |
122 | 112 |
| |
123 | 113 |
| |
124 | 114 |
| |
125 | 115 |
| |
126 |
| - | |
| 116 | + | |
| 117 | + | |
127 | 118 |
| |
128 | 119 |
| |
129 | 120 |
| |
|
0 commit comments
Comments
(0)