<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                inline 關鍵字允許函數體被直接插入到它們調用位置。這是一個強大的優化工具,但是應該審慎使用,并不是所有函數都適用inline行為。下面的例子演示了基本的用法: > The inline keyword allows function bodies to be directly inserted in place of calls to them. This can be a powerful optimization tool,but should be used judiciously as not all functions are good candidates for inline behavior. The following example demonstrates the basic usage: ~~~ class Main { static inline function mid(s1:Int, s2:Int) { return (s1 + s2) / 2; } static public function main() { var a = 1; var b = 2; var c = mid(a, b); } } ~~~ 生成的JavaScript輸出揭示了內聯的效果: > The generated JavaScript output reveals the effect of inline: ~~~ (function () { "use strict"; var Main = function() { } Main.main = function() { var a = 1; var b = 2; var c = (a + b) / 2; } Main.main(); })(); ~~~ 顯然,字段mid被生成的函數體(s1 + s2)/2替換掉了調用 mid(a,b),s1被替換為 a ,s2被替換為b。這可以避免一個函數調用,根據目標和出現的頻率,可以產生顯著的性能改進。 > As evident, the function body (s1 + s2) / 2 of ?eld mid was generated in place of the call to mid(a, b), with s1 being replaced by a and s2 being replaced by b. This avoids a function call which,depending on the target and frequency of occurrences,may yield noticeable performance improvements. 并不總是容易判斷是否一個函數要限定為內聯函數。沒有編寫表達式的短函數(如a=形式的賦值)通常是一個好的選擇,但是有時候更復雜的函數也可以使用內聯。然而,在一些情況下內聯可以實際上損害部分性能,例如,因為編譯器必須創建臨時變量服務于復雜的表達式。 > It is not always easy to judge if a function quali?es for being inline. Short functions that have no writing expressions (such as a = assignment) are usually a good choice, but even more complex functions can be candidates. However, in some cases inlining can actually be detrimental to performance, e.g. because the compiler has to create temporary variables for complex expressions. 內聯并不保證執行。編譯器可能由于多種原因取消內聯,用戶也可以通過 --no-inline 命令行參數來禁止內聯。唯一的例外是如果類是 extern(第6.2節)或者如果淚字段有 :extern 元數據(第6.9節),這種情況內聯被禁止。如果她不能被執行,編譯器發出一個錯誤。 > Inline is not guaranteed to be done. The compiler might cancel inlining for various reasons or a user could supply the --no-inline command line argument to disable inlining. The only exception is if the class is extern (6.2) or if the class ?eld has the :extern metadata (6.9), in which case inline is forced. If it cannot be done, the compiler emits an error. 重要的是依賴內聯時要記得這個: > It is important to remember this when relying on inline: ~~~ class Main { public static function main () { } static function test() { if (Math.random() > 0.5) { return "ok"; } else { error("random failed"); } } @:extern static inline function error(s:String) { throw s; } } ~~~ 如果正確的調用error是內聯的,程序編譯正確,因為控制流檢查器滿意內聯的throw(第5.22節)表達式。如果內聯部執行,編譯器只發現一個error函數的調用并發出錯誤 A return is missing here。 > If the call to error is inlined the program compiles correctly because the control ?ow checker is satis?ed due to the inlined throw (5.22) expression. If inline is not done,the compiler only sees a function call to error and emits the error A return is missing here.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看