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

fix:(ast) implement soft delete for Unset() #571

Merged
merged 8 commits into from Jan 2, 2024
Merged

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Dec 29, 2023

Background

  • Before v1.9.2, ast.Node.Unset() will hard delete child for one node. But since refactor:(ast) use linked chunk as fundamental storage for nodes #464 introduced llnked-chunk as storage, the behavior changed: Unset() will set an empty node at the index but still count it. This inconsistency disturbs our users, although current behavior sounds more reasonable asUnset(). Thus, we decide to be compatible with the old behavior.
  • Besides, UnsetByIndex() is not a behavior provided by std slice, we recommend users to use Add() and Pop() instead

Feature

  • Len() and Index() won't count emtpy nodes, as implemenation of soft-delete, which comes with overhead of index query O(N)
  • Add Pop(), Move() API as slice-like OP

@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2023

Codecov Report

Attention: 35 lines in your changes are missing coverage. Please review.

Comparison is base (ec2ab23) 78.57% compared to head (02ffc26) 78.57%.

Files Patch % Lines
ast/node.go 70.88% 14 Missing and 9 partials ⚠️
ast/buffer.go 86.41% 5 Missing and 6 partials ⚠️
ast/iterator.go 0.00% 0 Missing and 1 partial ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #571      +/-   ##
==========================================
- Coverage   78.57%   78.57%   -0.01%     
==========================================
  Files          69       69              
  Lines       10716    10823     +107     
==========================================
+ Hits         8420     8504      +84     
- Misses       1930     1942      +12     
- Partials      366      377      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@AsterDY AsterDY merged commit f806331 into main Jan 2, 2024
30 checks passed
@AsterDY AsterDY deleted the fix/soft_delete branch January 2, 2024 02:49
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.

None yet

3 participants