THIS Keyword Boosts the Performance of Your Kotlin Code🤯

preview_player
Показать описание

Рекомендации по теме
Комментарии
Автор

The entire code of doSomething() will be copied to your main function, so your main function will have three method calls from doSomething(), and doSomething() method will be removed

TamimProduction
Автор

Philip hi. I advise you to add subtitles to your short videos, so you will increase the coverage and make the material more receptive to people who do not speak their own English.good luck!

aiklklivlind
Автор

the compiler often inlines functions for you.
it can figure out when a function is only called in a limited scope, and optimize the build accordingly by itself.
there's actually an Android Studio inspection that will highlight the inline keyword and warn you that it's redundant, when it is.

as for his "boosting the performance" claim... well. only in specific scenarios, which i'd say are not typical.
typical mobile apps don't really perform complex calculations, and more specifically don't run loops that iterate like a 100, 000 times - performance bottlenecks are usually related to network calls and other I/O operations (database, files), layout rendering etc.inlining functions has got nothing to do with those

vibovitold
Автор

Keep doing these keyword tutorials. They're super helpful!

Function_And_Form
Автор

tried to make an inline function that just return a mathematical expression such as inline inline f(x, y)=y*width+x but the compiler warn me that the performance difference is insignificant

footballCartoon
Автор

Be careful is the word I am nervous about

orangasli
Автор

The kotlin documents says, the inline keyword affects both the function and it's parameters... So... The contents of doSomething function will be replaced in the majn function.... And also ... The doSomething function will not be deleted... It will be there in its place

venkataramananparameswaran
Автор

Why don't we make all the functions inline? Then the bytecode would contain only main function, isn't it good?

wrecking_ball_
Автор

Inline keyboard is not a guarantee for inline to happen - it is still due for compiler. Inline is not only beneficial for functions that accepts lambdas. It also useful to inline small function that used often. It's simple to calculate the theoretical benefit of inline by knowing the size of the function and the size of the code within the function for a particular language. Inline CAN effect the size of the app and compile time in a negative way. But due to decreased amount of references and better code (code is more visible for optimizers/shrinkers) optimization will ALWAYS effect app performance in a good way.

VilRapt
Автор

Instead of lambda function, it is better to say high order function.

mohsenrzna
Автор

why does it feel like your are reading on screen

vitquack