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

refactoring: CodeSelectorPModel do double copy of collectio in c-tor #3555

Closed
romani opened this Issue Nov 16, 2016 · 3 comments

Comments

Projects
None yet
3 participants
@rnveach

This comment has been minimized.

Show comment
Hide comment
@rnveach

rnveach Nov 16, 2016

Member

unmodifiableList may not really serve a purpose. We don't pass the field anywhere in that class, so we have no worries of modifications.

The array copy is most likely because we are worried about the list being modified from outside the class from where it was originally generated. unmodifiableList still references the list being copied.

The list is generated here, which does another array copy and 'unmodifiable'.
Which is again a list generated from here, which does another array copy and 'unmodifiable'.
All of which, is finally first generated here, when the file is first opened.

I think the code at MainFrameModel.java#L177 is valid. All the other array copies and 'unmodifiable' may be just extra protection to make sure we are not passing around a list that can be modified. One class won't know what its children are doing with it.

Member

rnveach commented Nov 16, 2016

unmodifiableList may not really serve a purpose. We don't pass the field anywhere in that class, so we have no worries of modifications.

The array copy is most likely because we are worried about the list being modified from outside the class from where it was originally generated. unmodifiableList still references the list being copied.

The list is generated here, which does another array copy and 'unmodifiable'.
Which is again a list generated from here, which does another array copy and 'unmodifiable'.
All of which, is finally first generated here, when the file is first opened.

I think the code at MainFrameModel.java#L177 is valid. All the other array copies and 'unmodifiable' may be just extra protection to make sure we are not passing around a list that can be modified. One class won't know what its children are doing with it.

@MEZk

This comment has been minimized.

Show comment
Hide comment
@MEZk

MEZk Nov 17, 2016

Contributor

@rnveach @romani
Collections.unmodifiableList does not create copy. It creates unmodifiable view of the list. It is a kind of wrapper which protects the list from being modified.

See
https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#unmodifiableList(java.util.List)

Contributor

MEZk commented Nov 17, 2016

@rnveach @romani
Collections.unmodifiableList does not create copy. It creates unmodifiable view of the list. It is a kind of wrapper which protects the list from being modified.

See
https://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#unmodifiableList(java.util.List)

@rnveach rnveach added the easy label Mar 2, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 1, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 1, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 1, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 1, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 2, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 19, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue May 24, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue Jun 10, 2017

Kietzmann added a commit to Kietzmann/checkstyle that referenced this issue Jul 4, 2017

Kietzmann pushed a commit to Kietzmann/checkstyle that referenced this issue Jul 5, 2017

Kietzmann pushed a commit to Kietzmann/checkstyle that referenced this issue Jul 5, 2017

Kietzmann pushed a commit to Kietzmann/checkstyle that referenced this issue Jul 6, 2017

romani added a commit that referenced this issue Jul 6, 2017

@romani romani added this to the 8.1 milestone Jul 6, 2017

@romani

This comment has been minimized.

Show comment
Hide comment
@romani

romani Jul 6, 2017

Member

fix is merged

Member

romani commented Jul 6, 2017

fix is merged

@romani romani closed this Jul 6, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment