forked from FuelLabs/sway
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Sway Reference: Section 9 Annotations inline (FuelLabs#4636)
- Loading branch information
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
docs/reference/src/documentation/language/annotations/attributes/inline.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Inline | ||
|
||
When making a call the compiler may generate code to call a function where it is defined or it may copy the function code (inline) to prevent additional code generation. | ||
|
||
The Sway compiler automatically inlines functions based on internal heuristics; however, the `inline` attribute may be used to suggest, but not require, code generation or code copying. | ||
|
||
## Generate code | ||
|
||
To suggest code generation use the `never` keyword. | ||
|
||
```sway | ||
{{#include ../../../../code/language/annotations/src/main.sw:never_inline}} | ||
``` | ||
|
||
## Copy code | ||
|
||
To suggest code copy use the `always` keyword. | ||
|
||
```sway | ||
{{#include ../../../../code/language/annotations/src/main.sw:always_inline}} | ||
``` |