Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor AxPropertyDescriptor to replace ArrayList #8152

Merged
merged 3 commits into from
Nov 10, 2022

Conversation

elachlan
Copy link
Contributor

@elachlan elachlan commented Nov 9, 2022

Refactored AxPropertyDescriptor to replace ArrayList with List<T>

Related: #8140

Microsoft Reviewers: Open in CodeFlow

@elachlan elachlan requested a review from a team as a code owner November 9, 2022 22:24
@ghost ghost assigned elachlan Nov 9, 2022
@elachlan
Copy link
Contributor Author

elachlan commented Nov 9, 2022

There is a section where there is a CopyTo call:

Attribute[] temp = new Attribute[attributes.Count];
attributes.CopyTo(temp, 0);
AttributeArray = temp;

Should I use ToArray() on the List instead? I wanted to keep the changes to a minimum hence why I didn't do it.

@dreddy-work
Copy link
Member

Should I use ToArray() on the List instead? I wanted to keep the changes to a minimum hence why I didn't do it.

I don't see why not. it creates a new copy of array.

@RussKie RussKie enabled auto-merge (squash) November 10, 2022 01:56
@RussKie RussKie merged commit 00b4091 into dotnet:main Nov 10, 2022
@ghost ghost added this to the 8.0 Preview1 milestone Nov 10, 2022
@elachlan elachlan deleted the AxPropertyDescriptor-ArrayList branch November 10, 2022 02:17
@@ -268,16 +267,13 @@ internal void UpdateAttributes()
return;
}

ArrayList attributes = new ArrayList(AttributeArray);
List<Attribute> attributes = new(AttributeArray);
foreach (Attribute attr in _updateAttributes)
{
attributes.Add(attr);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this foreach equal to
attributes.AddRange(_updateAttributes);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea. Could you put in a PR?

@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants