Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
xliu79 committed Jul 20, 2020
1 parent c5e370d commit a4d0f84
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions english/basic_content/inline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,26 +70,26 @@ int main()

}
/**
* 编译器对 inline 函数的处理步骤
* inline 函数体复制到 inline 函数调用点处;
* 为所用 inline 函数中的局部变量分配内存空间;
* inline 函数的的输入参数和返回值映射到调用方法的局部变量空间中;
* 如果 inline 函数有多个返回点,将其转变为 inline 函数代码块末尾的分支(使用 GOTO)。
* Compiler's processing steps for inline function
* Copy the body of the inline function to the call point of the inline function;
* Allocate memory space for local variables in the inline function used
* The input parameters and return values of the inline function are mapped to the local variable space of the calling method
* If the inline function has multiple return points, convert it to a branch at the end of the inline function code block (using goto)
*/

```
内联能提高函数效率,但并不是所有的函数都定义成内联函数!内联是以代码膨胀(复制)为代价,仅仅省去了函数调用的开销,从而提高函数的执行效率。
Inline can improve the efficiency of functions, but not all functions are defined as inline functions!内联是以代码膨胀(复制)为代价,仅仅省去了函数调用的开销,从而提高函数的执行效率。
- 如果执行函数体内代码的时间相比于函数调用的开销较大,那么效率的收货会更少
-If the execution time of the code in the function body is higher than the cost of function call, the efficiency of receiving goods will be less
- 另一方面,每一处内联函数的调用都要复制代码,将使程序的总代码量增大,消耗更多的内存空间。
- On the other hand, every call of inline function will copy the code, which will increase the total code of the program and consume more memory space
以下情况不宜用内联
Inline is not suitable for the following situations
(1)如果函数体内的代码比较长,使得内联将导致内存消耗代价比较高。
(1)If the code in the function body is long, it will lead to high memory consumption
(2)如果函数体内出现循环,那么执行函数体内代码的时间要比函数调用的开销大
(2)If there is a loop in the function body, it takes more time to execute the code in the function body than the cost of the function call
## 2.Could virtual be inline function?
Expand Down

0 comments on commit a4d0f84

Please sign in to comment.