@@ -148,8 +148,8 @@ pg_popcount_available(void)
148
148
* the function pointers so that subsequent calls are routed directly to
149
149
* the chosen implementation.
150
150
*/
151
- static int
152
- pg_popcount32_choose ( uint32 word )
151
+ static inline void
152
+ choose_popcount_functions ( void )
153
153
{
154
154
if (pg_popcount_available ())
155
155
{
@@ -163,45 +163,26 @@ pg_popcount32_choose(uint32 word)
163
163
pg_popcount64 = pg_popcount64_slow ;
164
164
pg_popcount = pg_popcount_slow ;
165
165
}
166
+ }
166
167
168
+ static int
169
+ pg_popcount32_choose (uint32 word )
170
+ {
171
+ choose_popcount_functions ();
167
172
return pg_popcount32 (word );
168
173
}
169
174
170
175
static int
171
176
pg_popcount64_choose (uint64 word )
172
177
{
173
- if (pg_popcount_available ())
174
- {
175
- pg_popcount32 = pg_popcount32_fast ;
176
- pg_popcount64 = pg_popcount64_fast ;
177
- pg_popcount = pg_popcount_fast ;
178
- }
179
- else
180
- {
181
- pg_popcount32 = pg_popcount32_slow ;
182
- pg_popcount64 = pg_popcount64_slow ;
183
- pg_popcount = pg_popcount_slow ;
184
- }
185
-
178
+ choose_popcount_functions ();
186
179
return pg_popcount64 (word );
187
180
}
188
181
189
182
static uint64
190
183
pg_popcount_choose (const char * buf , int bytes )
191
184
{
192
- if (pg_popcount_available ())
193
- {
194
- pg_popcount32 = pg_popcount32_fast ;
195
- pg_popcount64 = pg_popcount64_fast ;
196
- pg_popcount = pg_popcount_fast ;
197
- }
198
- else
199
- {
200
- pg_popcount32 = pg_popcount32_slow ;
201
- pg_popcount64 = pg_popcount64_slow ;
202
- pg_popcount = pg_popcount_slow ;
203
- }
204
-
185
+ choose_popcount_functions ();
205
186
return pg_popcount (buf , bytes );
206
187
}
207
188
0 commit comments