Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6687430

Browse files
Refactor code for setting pg_popcount* function pointers.
Presently, there are three copies of this code, and a proposedfollow-up patch would add more code to each copy. This commitintroduces a new inline function for this code and makes use of itin the pg_popcount*_choose functions, thereby reducing codeduplication.Author: Paul AmonsonDiscussion:https://postgr.es/m/BL1PR11MB5304097DF7EA81D04C33F3D1DCA6A%40BL1PR11MB5304.namprd11.prod.outlook.com
1 parent38698dd commit6687430

File tree

1 file changed

+9
-28
lines changed

1 file changed

+9
-28
lines changed

‎src/port/pg_bitutils.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ pg_popcount_available(void)
148148
* the function pointers so that subsequent calls are routed directly to
149149
* the chosen implementation.
150150
*/
151-
staticint
152-
pg_popcount32_choose(uint32word)
151+
staticinlinevoid
152+
choose_popcount_functions(void)
153153
{
154154
if (pg_popcount_available())
155155
{
@@ -163,45 +163,26 @@ pg_popcount32_choose(uint32 word)
163163
pg_popcount64=pg_popcount64_slow;
164164
pg_popcount=pg_popcount_slow;
165165
}
166+
}
166167

168+
staticint
169+
pg_popcount32_choose(uint32word)
170+
{
171+
choose_popcount_functions();
167172
returnpg_popcount32(word);
168173
}
169174

170175
staticint
171176
pg_popcount64_choose(uint64word)
172177
{
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();
186179
returnpg_popcount64(word);
187180
}
188181

189182
staticuint64
190183
pg_popcount_choose(constchar*buf,intbytes)
191184
{
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();
205186
returnpg_popcount(buf,bytes);
206187
}
207188

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp