The INLINE
pragma specifys that a subprogram call is, or is not, to be inlined. Inlining replaces a subprogram call (to a subprogram in the same program unit) with a copy of the called subprogram.
Keyword and Parameter Descriptions
Signifies that the statement is a pragma (compiler directive). Pragmas are processed at compile time, not at run time. They pass information to the compiler.
The name of a subprogram.
If PLSQL_OPTIMIZE_LEVEL=2
, YES
specifies that the subprogram call is to be inlined.
If PLSQL_OPTIMIZE_LEVEL=3
, YES
specifies that the subprogram call has a high priority for inlining.
Specifies that the subprogram call is not to be inlined.
The INLINE
pragma affects only the immediately following declaration or statement, and only some kinds of statements.
When the INLINE
pragma immediately precedes one of the following statements, the pragma affects every call to the specified subprogram in that statement (see Example 13-1):
Assignment
Call
Conditional
CASE
CONTINUE-WHEN
EXECUTE IMMEDIATE
EXIT-WHEN
LOOP
RETURN
The INLINE
pragma does not affect statements that are not in the preceding list.
When the INLINE
pragma immediately precedes a declaration, it affects the following:
Every call to the specified subprogram in that declaration
Every initialization value in that declaration except the default initialization values of records
If the name of the subprogram (identifier
) is overloaded (that is, if it belongs to more than one subprogram), the INLINE
pragma applies to every subprogram with that name (see Example 13-2). For information about overloaded subprogram names, see Overloading PL/SQL Subprogram Names.
The PRAGMA
INLINE (
identifier,
'YES')
very strongly encourages the compiler to inline a particular call, but the compiler might not to do so if other considerations or limits make the inlining undesirable. If you specify PRAGMA INLINE (
identifier,
'NO')
, the compiler does not inline calls to subprograms named identifier
(see Example 13-3).
Multiple pragmas can affect the same declaration or statement. Each pragma applies its own effect to the statement. If PRAGMA
INLINE(
identifier,
'YES')
and PRAGMA INLINE (
identifier,
'NO')
have the same identifier
, 'NO'
overrides 'YES'
(see Example 13-4). One PRAGMA INLINE (
identifier,
'NO')
overrides any number of occurrences of PRAGMA INLINE (
identifier,
'YES')
, and the order of these pragmas is not important.
In Example 13-1 and Example 13-2, assume that PLSQL_OPTIMIZE_LEVEL=2
.
In Example 13-1, the INLINE
pragma affects the procedure calls p1(1)
and p1(2)
, but not the procedure calls p1(3)
and p1(4)
.
Example 13-1 Specifying that a Subprogram Is To Be Inlined
PROCEDURE p1 (x PLS_INTEGER) IS ...
...
PRAGMA INLINE (p1, 'YES');
x:= p1(1) + p1(2) + 17; -- These 2 calls to p1 will be inlined
...
x:= p1(3) + p1(4) + 17; -- These 2 calls to p1 will not be inlined
...
In Example 13-2 the INLINE
pragma affects both functions named p2
.
Example 13-2 Specifying that an Overloaded Subprogram Is To Be Inlined
FUNCTION p2 (p boolean) return PLS_INTEGER IS ...
FUNCTION p2 (x PLS_INTEGER) return PLS_INTEGER IS ...
...
PRAGMA INLINE(p2, 'YES');
x := p2(true) + p2(3);
...
In Example 13-3, assume that PLSQL_OPTIMIZE_LEVEL=3
. The INLINE
pragma affects the procedure calls p1(1)
and p1(2)
, but not the procedure calls p1(3)
and p1(4)
.
Example 13-3 Specifying that a Subprogram Is Not To Be Inlined
PROCEDURE p1 (x PLS_INTEGER) IS ...
...
PRAGMA INLINE (p1, 'NO');
x:= p1(1) + p1(2) + 17; -- These 2 calls to p1 will not be inlined
...
x:= p1(3) + p1(4) + 17; -- These 2 calls to p1 might be inlined
...
PRAGMA
INLINE
... 'NO'
overrides PRAGMA
INLINE
... 'YES'
for the same subprogram, regardless of their order in the code. In Example 13-4, the second INLINE
pragma overrides both the first and third INLINE
pragmas.