Might be a decompiler bug. Can you show the real b...
# announcements
c
Might be a decompiler bug. Can you show the real bytecode here?
i
I am seeing again with while, isNullOrEmpty and other functions
https://pastebin.com/JJnLJ3Hx here for bytecode for isNullOrEmpty that is showing boolean var3 = false; boolean var4 = false;
c
Yeah, that's odd. Looks like it's indeed like this in the bytecode.
i
decompiler bug?
c
No, I mean the useless variable indeed seems to be in the bytecode. Unless I'm missing something.
You can see
ICONST_0
twice followed by
ISTORE_3
/
ISTORE_4
to store the value
0
(=
false
) into the variables 3 and 4, but there's no
ILOAD_3
/
ILOAD_4
to ever load it again.
m
I've seen medum article recommending using if instead of let because of extra variable in bytecode.
c
That's not good advice, and generally the article is of low quality. This should be something that's very easy to optimize for the JVM or ART. And even if not, it's a stack allocation, which are really cheap.
m
I guess kotlin compiler tests don't check for scenarios like these and this slipped in by accident
I mean, this bytecode is functionally correct, but it's not optimal
c
It's not optimal, but I would be surprised to see an actual performance impact.
i
Android Studio has Kotlin Bytecode with Optimizations checked, it still show same as unoptimizations
c
That doesn't include optimizations performed at runtime by ART or the JVM.
i
odd
g
This is not a bug, this variable used for inline functions debugging See: https://kotlinlang.slack.com/archives/C7L3JB43G/p1558022163043700?thread_ts=1557907293.041100&cid=C7L3JB43G
c
Ah, thanks! That's clever.