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

Commita8593a3

Browse files
committed
Convert MemoryContextSwitchTo() into an inline function when using GCC.
1 parent477a64d commita8593a3

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

‎src/backend/utils/mmgr/mcxt.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
*
1515
*
1616
* IDENTIFICATION
17-
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.53 2004/12/31 22:02:48 pgsql Exp $
17+
* $PostgreSQL: pgsql/src/backend/utils/mmgr/mcxt.c,v 1.54 2005/02/18 21:52:33 tgl Exp $
1818
*
1919
*-------------------------------------------------------------------------
2020
*/
@@ -619,7 +619,13 @@ repalloc(void *pointer, Size size)
619619
/*
620620
* MemoryContextSwitchTo
621621
*Returns the current context; installs the given context.
622+
*
623+
* This is inlined when using GCC.
624+
*
625+
* TODO: investigate supporting inlining for some non-GCC compilers.
622626
*/
627+
#ifndef__GNUC__
628+
623629
MemoryContext
624630
MemoryContextSwitchTo(MemoryContextcontext)
625631
{
@@ -632,6 +638,8 @@ MemoryContextSwitchTo(MemoryContext context)
632638
returnold;
633639
}
634640

641+
#endif/* ! __GNUC__ */
642+
635643
/*
636644
* MemoryContextStrdup
637645
*Like strdup(), but allocate from the specified context

‎src/include/utils/palloc.h

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
2222
* Portions Copyright (c) 1994, Regents of the University of California
2323
*
24-
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.32 2004/12/31 22:03:46 pgsql Exp $
24+
* $PostgreSQL: pgsql/src/include/utils/palloc.h,v 1.33 2005/02/18 21:52:34 tgl Exp $
2525
*
2626
*-------------------------------------------------------------------------
2727
*/
@@ -70,8 +70,26 @@ extern void pfree(void *pointer);
7070

7171
externvoid*repalloc(void*pointer,Sizesize);
7272

73+
/*
74+
* MemoryContextSwitchTo can't be a macro in standard C compilers.
75+
* But we can make it an inline function when using GCC.
76+
*/
77+
#ifdef__GNUC__
78+
79+
static __inline__MemoryContext
80+
MemoryContextSwitchTo(MemoryContextcontext)
81+
{
82+
MemoryContextold=CurrentMemoryContext;
83+
CurrentMemoryContext=context;
84+
returnold;
85+
}
86+
87+
#else
88+
7389
externMemoryContextMemoryContextSwitchTo(MemoryContextcontext);
7490

91+
#endif/* __GNUC__ */
92+
7593
/*
7694
* These are like standard strdup() except the copied string is
7795
* allocated in a context, not with malloc().

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp