Rewrite compound assignment in a single expression#120
Conversation
|
Uhm, it seems that computing the ptr and storing it in a temporary variable is a good thing for long expressions. This change regresses the performance in those cases. Can we keep that part? |
So it should be: {
let _ptr = ptr.clone;
_ptr.write(_ptr.read() + 1)
}? |
I did this |
| " ", rhs_as_string, "; __ptr.write(__tmp) }"); | ||
| { | ||
| PushBrace brace(*this); | ||
| StrCat(std::format("let _ptr = {}.clone();", ptr)); |
There was a problem hiding this comment.
why doesn't this use the emitFreshPointer functionality instead of always doing a clone?
There was a problem hiding this comment.
No good reason. I will replace with ConvertFreshPointer
There was a problem hiding this comment.
I took a closer look and it's not trivial to replace with ConvertFreshPointer. This path uses the pending_deref_ mechanism. pending_deref_ is generally used for rewriting mutable method receivers to use Ptr::with_mut. Or more generally, to convert pointer dereferences in AddrOf/LValue contexts.
pending_deref_ is triggered inside ConvertLValue, line 1796 above, so every user of ConvertLValue must also check pending_deref_.
No description provided.