#Operator
31 messages ยท Page 1 of 1 (latest)
โ This post has been reserved for your question.
Hey @slate abyss! Please use
/closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.
there are situation where that's needed for network traffic, some cryptographic things or communication with some other devices
and sometimes also things like checksums
sometimes for parsing binary files or similar
or if you have some sort of (small) bitmap in general or similar
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
but the question now is t that how much i worked and invest time in them or just skipped them
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
One thing I like to use in Java since there is no negative indexing to get the n-th last element, is to write list.get(list.size() + ~n) which will do exactly that.
alternatively list.reversed().get(n) - we don't need that legacy code
I wouldn't recommend that in the same way as I wouldn't recommend XOR swapping
code should be readable and doing it with + ~n adds cognitive overhead (people have to think about it to check for correctness)
I don't use it in production code. Only for Codewars.
I don't trust the jvm to be capable of optimizing this.
Premature optimization is the root of all evil. It won't optimize it if it isn't hot either way.
But I hate garbage.
and if it is hot, C2/Graal/Falcon(?) might
- inline the
reversed()andget()methods - remove the allocation/move it to the stack
- extract the calculation
- do it directly in the generated code
Not trusting the JVMto optimize it is not a valid argument unless (all of the following must be true for it to be a valid argument)
- Profiling shows that code is important for performance
- Bemchmarks have been made and they show it is a significant improvement
What makes you think it can optimize list.get(list.size() + ~n) better? Do you have evidence for it?
Also, if it's relevant for performance, are you using List, ArrayList or the array directly as the static type?
Right, virtual method lookups are already bad. Field accesses to get the size. Ultra bad. I only trust bitarithmetics because that's what CPUs are made for.
interface calls (invokeinterface) are often worse than normal virtual lookups (invokevirtual). They can be inlined but it adds additional CPU instructions for checks and it cannot do inlay caching that well.
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.
some apis use int bits as boolean which you have to connect with | to get what you want in some cases.
an example for this is specifying multiple foreground service types in android
๐ค Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived.
If your question was not answered yet, feel free to re-open this post or create a new one.
In case your post is not getting any attention, you can try to use/help ping.
Warning: abusing this will result in moderative actions taken against you.