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

Commit4d371d9

Browse files
committed
Remove an unnecessary loop in snapshot merging procedure.
1 parent0335888 commit4d371d9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

‎contrib/pg_xtm/pg_dtm.c‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ static bool TransactionIdIsInDoubt(TransactionId xid)
146146

147147
staticvoidDtmMergeSnapshots(Snapshotdst,Snapshotsrc)
148148
{
149-
inti,j,n;
149+
inti,j;
150150
TransactionIdxid;
151151

152152
Assert(TransactionIdIsValid(src->xmin)&&TransactionIdIsValid(src->xmax));
@@ -173,20 +173,17 @@ static void DtmMergeSnapshots(Snapshot dst, Snapshot src)
173173
//MyPgXact->xmin = TransactionXmin = src->xmin;
174174
}
175175
if (src->xmax<dst->xmax)dst->xmax=src->xmax;
176+
// concatenate two active lists
177+
memcpy(dst->xip+dst->xcnt,src->xip,src->xcnt*sizeof(TransactionId));
178+
dst->xcnt+=src->xcnt;
179+
Assert(dst->xcnt <=GetMaxSnapshotXidCount());
176180

177-
178-
n=dst->xcnt;
179-
for (xid=dst->xmax;xid <=src->xmin;xid++) {
180-
dst->xip[n++]=xid;
181-
}
182-
memcpy(dst->xip+n,src->xip,src->xcnt*sizeof(TransactionId));
183-
n+=src->xcnt;
184-
Assert(n <=GetMaxSnapshotXidCount());
185-
186-
qsort(dst->xip,n,sizeof(TransactionId),xidComparator);
181+
// sort the list
182+
qsort(dst->xip,dst->xcnt,sizeof(TransactionId),xidComparator);
187183
xid=InvalidTransactionId;
188184

189-
for (i=0,j=0;i<n&&dst->xip[i]<dst->xmax;i++) {
185+
// remove duplicates
186+
for (i=0,j=0;i<dst->xcnt&&dst->xip[i]<dst->xmax;i++) {
190187
if (dst->xip[i]!=xid) {
191188
dst->xip[j++]=xid=dst->xip[i];
192189
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp