forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitf0705bb
committed
Add functions to calculate the next power of 2
There are many areas in the code where we need to determine the nexthighest power of 2 of a given number. We tend to always do that in anad-hoc way each time, generally with some tight for loop which performs abitshift left once per loop and goes until it finds a number above thegiven number.Here we add two generic functions which make use of the existingpg_leftmost_one_pos* functions which, when available, will allow us tocalculate the next power of 2 without any looping.Here we don't add any code which uses these new functions. That will bedone in follow-up commits.Author: David Fetter, with some minor adjustments by meReviewed-by: John Naylor, Jesse ZhangDiscussion:https://postgr.es/m/20200114173553.GE32763%40fetter.org1 parent7a5d74b commitf0705bb
1 file changed
+72
-0
lines changedLines changed: 72 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
129 | 129 |
| |
130 | 130 |
| |
131 | 131 |
| |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
132 | 204 |
| |
133 | 205 |
| |
134 | 206 |
| |
|
0 commit comments
Comments
(0)