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

Improvements to List and Set in ds package #24

Merged
merged 1 commit into from
Aug 23, 2023
Merged

Conversation

mokiat
Copy link
Owner

@mokiat mokiat commented Aug 22, 2023

The following changes are made:

  • Adds a new ds.ListFromSlice for easier initialization of a *ds.List type.
  • Adds Equals methods to *ds.Set and *ds.List types.
  • Adds Unbox methods to *ds.Set and *ds.List types. This can be used for fast access to their inner representations. Potentially unsafe if misused.
  • Adds a Set method to *ds.List so that an item at a specific index can be modified, similarly to how it can be retrieved with Get.
  • Changes the behavior of *ds.List.Items method. Previously it returned the inner slice and now it returns a copy. Instead Unbox should be used.

WARNING The last change is a backward incompatible change. The impact is that existing apps will allocate memory where Items has been used until they migrate to Unbox. Furthermore, if existing apps did modify the slice (which hopefully they didn't as the documentation advised) as a means to mutate the List, that will no longer work correctly.

@mokiat mokiat requested a review from Bo0mer August 22, 2023 19:02
Copy link
Collaborator

@Bo0mer Bo0mer left a comment

Choose a reason for hiding this comment

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

LGTM

@mokiat mokiat merged commit 040457e into master Aug 23, 2023
@mokiat mokiat deleted the ds_improvements branch August 23, 2023 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants