This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Use SaveAndRestore to simplify code
AbandonedPublic

Authored by MaskRay on Oct 31 2018, 11:39 PM.

Details

Event Timeline

MaskRay created this revision.Oct 31 2018, 11:39 PM
grimar added a comment.Nov 1 2018, 1:45 AM

I believe Rui was not happy when I tried to use SaveAndRestore in one of my patches.
And honestly looking at this change I think now I understand why. It is shorter, but I would not call the new code simpler.
I'll leave this up to Rui.

ruiu added a comment.Nov 1 2018, 4:43 AM

Yeah, honestly I don't like SaveAndRestore. You can save one line per a use of SaveAndRestore, but instead everybody reading or writing the code need to learn what SaveAndRestore is. On the other hand, saving old values using local variables and assignments is really easy to read (besides that theoretically they could be overridden by operator overloading). SaveAndRestore is not a complicated class, so it's worth to learn how to use it if you have a lot of use cases of SaveAndRestore here, but three uses is too few.

MaskRay abandoned this revision.Nov 1 2018, 9:21 AM