/ go Public
cmd/compile: optimize struct reset logic #52373
Issues related to the Go compiler and/or runtime.
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Consider the following:
Both snippets are semantically equivalent, but
ResetBis much faster.
ResetAis common in reset logic where the intention is to reset all fields except a few select fields. This pattern is more maintainable since it properly resets the struct even if new fields are added to it later on.
The compiler should recognize the pattern exhibited in
ResetAand avoid the unnecessary copy of
s.Large = s.Large.
The text was updated successfully, but these errors were encountered: