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

Commitd63d957

Browse files
committed
Convert macros to static inline functions (block.h)
Remove BlockIdIsValid(), which wasn't used and is unnecessary.Remove BlockIdCopy(), which wasn't used and can be done by structassignment.(BlockIdEquals() also isn't used, but seems reasonable to keeparound.)Reviewed-by: Amul Sul <sulamul@gmail.com>Discussion:https://www.postgresql.org/message-id/flat/5b558da8-99fb-0a99-83dd-f72f05388517%40enterprisedb.com
1 parent495ed0e commitd63d957

File tree

1 file changed

+23
-30
lines changed

1 file changed

+23
-30
lines changed

‎src/include/storage/block.h

Lines changed: 23 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,57 +59,50 @@ typedef struct BlockIdData
5959
typedefBlockIdData*BlockId;/* block identifier */
6060

6161
/* ----------------
62-
*supportmacros
62+
*supportfunctions
6363
* ----------------
6464
*/
6565

6666
/*
6767
* BlockNumberIsValid
6868
*True iff blockNumber is valid.
6969
*/
70-
#defineBlockNumberIsValid(blockNumber) \
71-
((BlockNumber) (blockNumber) != InvalidBlockNumber)
72-
73-
/*
74-
* BlockIdIsValid
75-
*True iff the block identifier is valid.
76-
*/
77-
#defineBlockIdIsValid(blockId) \
78-
PointerIsValid(blockId)
70+
staticinlinebool
71+
BlockNumberIsValid(BlockNumberblockNumber)
72+
{
73+
returnblockNumber!=InvalidBlockNumber;
74+
}
7975

8076
/*
8177
* BlockIdSet
8278
*Sets a block identifier to the specified value.
8379
*/
84-
#defineBlockIdSet(blockId,blockNumber) \
85-
( \
86-
(blockId)->bi_hi = (blockNumber) >> 16, \
87-
(blockId)->bi_lo = (blockNumber) & 0xffff \
88-
)
89-
90-
/*
91-
* BlockIdCopy
92-
*Copy a block identifier.
93-
*/
94-
#defineBlockIdCopy(toBlockId,fromBlockId) \
95-
( \
96-
(toBlockId)->bi_hi = (fromBlockId)->bi_hi, \
97-
(toBlockId)->bi_lo = (fromBlockId)->bi_lo \
98-
)
80+
staticinlinevoid
81+
BlockIdSet(BlockIdData*blockId,BlockNumberblockNumber)
82+
{
83+
blockId->bi_hi=blockNumber >>16;
84+
blockId->bi_lo=blockNumber&0xffff;
85+
}
9986

10087
/*
10188
* BlockIdEquals
10289
*Check for block number equality.
10390
*/
104-
#defineBlockIdEquals(blockId1,blockId2) \
105-
((blockId1)->bi_hi == (blockId2)->bi_hi && \
106-
(blockId1)->bi_lo == (blockId2)->bi_lo)
91+
staticinlinebool
92+
BlockIdEquals(constBlockIdData*blockId1,constBlockIdData*blockId2)
93+
{
94+
return (blockId1->bi_hi==blockId2->bi_hi&&
95+
blockId1->bi_lo==blockId2->bi_lo);
96+
}
10797

10898
/*
10999
* BlockIdGetBlockNumber
110100
*Retrieve the block number from a block identifier.
111101
*/
112-
#defineBlockIdGetBlockNumber(blockId) \
113-
((((BlockNumber) (blockId)->bi_hi) << 16) | ((BlockNumber) (blockId)->bi_lo))
102+
staticinlineBlockNumber
103+
BlockIdGetBlockNumber(constBlockIdData*blockId)
104+
{
105+
return (((BlockNumber)blockId->bi_hi) <<16) | ((BlockNumber)blockId->bi_lo);
106+
}
114107

115108
#endif/* BLOCK_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp