Skip to content

Commit

Permalink
Avoid cloning FragmentOptions if the instance is already normalized.
Browse files Browse the repository at this point in the history
RELNOTES: None.
PiperOrigin-RevId: 244682258
  • Loading branch information
Googler authored and copybara-github committed Apr 22, 2019
1 parent 8bd7e48 commit 30306d5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ public FragmentOptions getHost() {

@Override
public Options getNormalized() {
Options result = (Options) super.getNormalized();
Options result = (Options) clone();

if (collapseDuplicateDefines) {
LinkedHashMap<String, String> flagValueByName = new LinkedHashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,10 @@ public FragmentOptions getHost() {
}

/**
* Creates a new instance of this {@code FragmentOptions} with all flags adjusted to be suitable
* for forming configurations.
* Returns an instance of {@code FragmentOptions} with all flags adjusted to be suitable for
* forming configurations.
*
* <p>If this instance is already suitable, it will be returned without creating a new instance.
*
* <p>Motivation: Sometimes a fragment's physical option values, as set by the options parser, do
* not correspond to their logical interpretation. For example, an option may need custom code to
Expand All @@ -71,7 +73,7 @@ public FragmentOptions getHost() {
* method. Step 2) is the responsibility of each transition implementation.
*/
public FragmentOptions getNormalized() {
return clone();
return this;
}

/** Tracks limitations on referring to an option in a {@code config_setting}. */
Expand Down

0 comments on commit 30306d5

Please sign in to comment.