Skip to content

Commit 15269b5

Browse files
committed
Avoid useless loop overhead in AtEOXact routines when the backend is
compiled with USE_ASSERT_CHECKING but is running with assert_enabled false.
1 parent 4568e0f commit 15269b5

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

src/backend/storage/buffer/bufmgr.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.191 2005/08/08 03:11:44 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/storage/buffer/bufmgr.c,v 1.192 2005/08/08 19:44:22 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -1067,15 +1067,18 @@ void
10671067
AtEOXact_Buffers(bool isCommit)
10681068
{
10691069
#ifdef USE_ASSERT_CHECKING
1070-
int i;
1071-
1072-
for (i = 0; i < NBuffers; i++)
1070+
if (assert_enabled)
10731071
{
1074-
Assert(PrivateRefCount[i] == 0);
1072+
int i;
1073+
1074+
for (i = 0; i < NBuffers; i++)
1075+
{
1076+
Assert(PrivateRefCount[i] == 0);
1077+
}
10751078
}
1079+
#endif
10761080

10771081
AtEOXact_LocalBuffers(isCommit);
1078-
#endif
10791082

10801083
/* Make sure we reset the strategy hint in case VACUUM errored out */
10811084
StrategyHintVacuum(false);

src/backend/storage/buffer/localbuf.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.67 2005/05/29 04:23:04 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/storage/buffer/localbuf.c,v 1.68 2005/08/08 19:44:22 tgl Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -308,11 +308,14 @@ void
308308
AtEOXact_LocalBuffers(bool isCommit)
309309
{
310310
#ifdef USE_ASSERT_CHECKING
311-
int i;
312-
313-
for (i = 0; i < NLocBuffer; i++)
311+
if (assert_enabled)
314312
{
315-
Assert(LocalRefCount[i] == 0);
313+
int i;
314+
315+
for (i = 0; i < NLocBuffer; i++)
316+
{
317+
Assert(LocalRefCount[i] == 0);
318+
}
316319
}
317320
#endif
318321
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy