Класс scala.noinline
final class noinline extends StaticAnnotation
Аннотация для методов, которые оптимизатор не должен встраивать.
Обратите внимание, что по умолчанию Scala оптимизатор отключен и никакие места вызова не встраиваются. См. -opt:help для получения информации о том, как включить оптимизатор и встраиватель.
Когда встраивание включено, встраиватель никогда не будет встраивать методы или места вызова, помеченные @noinline.
Примеры:
@inline final def f1(x: Int) = x
@noinline final def f2(x: Int) = x
final def f3(x: Int) = x
def t1 = f1(1) // inlined if possible
def t2 = f2(1) // not inlined
def t3 = f3(1) // may be inlined (the inliner heuristics can select the callsite)
def t4 = f1(1): @noinline // not inlined (override at callsite)
def t5 = f2(1): @inline // inlined if possible (override at callsite)
def t6 = f3(1): @inline // inlined if possible
def t7 = f3(1): @noinline // not inlined
}
Примечание: скобки необходимы при аннотировании места вызова внутри более крупного выражения.
def t1 = f1(1) + f1(1): @noinline // equivalent to (f1(1) + f1(1)): @noinline def t2 = f1(1) + (f1(1): @noinline) // the second call to f1 is not inlined
| Супертипы |
|---|
© 2002-2022 EPFL, with contributions from Lightbend.
Licensed under the Apache License, Version 2.0.
https://scala-lang.org/api/3.1.1/scala/noinline.html