Improve compact diff API #24
No reviewers
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
question
rust
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: andras/reconcile#24
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "asch/refactor-api"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Features
Breaks
is_binaryfrom the APIAdditional changes
isize::MAXwrapping into explicit panicsPull Request Overview
This PR refactors the compact diff API to remove dependencies on serde within WASM and improve the API design. The key changes include removing the deprecated
is_binaryfunction, simplifying the diff representation by removing cursor positions, and returning native JavaScript arrays instead of JSON strings from WASM.Key changes:
ChangeSetwithNumberOrStringenum for a simpler diff representationis_binaryutility and integrated its logic directly into WASM functionsgetCompactDiffto return JavaScript arrays instead of JSON stringsReviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated 6 comments.
Show a summary per file
getCompactDiffto_changes/from_changesAPIget_compact_diffto returnVec<JsValue>, removedis_binaryexport, integrated binary detection inlineis_binaryutility moduleis_binarymoduleNumberOrStringenum with WASM and serde supportnumber_or_stringmoduleChangeSetandSimpleOperationtypesto_change_set/from_change_setwithto_changes/from_changesusingNumberOrStringChangeSetisBinaryfunctionserde_jsondependency from wasm feature, updated feature flags💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Using
i64::MAXas a fallback for overflow in length conversion is problematic. Ifprev_lengthexceedsi64::MAX, this will create an incorrect positive number instead of properly handling the error. Consider using a saturating conversion or returning an error instead.Using
i64::MAXas a fallback and then negating it will result ini64::MIN + 1due to overflow, creating incorrect delete operation sizes. This should handle overflow errors explicitly or use saturating arithmetic.Using
usize::MAXas a fallback when converting fromi64tousizecan cause incorrect behavior. If the conversion fails due to a negative number that passed the>= 0check, this creates an enormous positive length. Use proper error handling instead.Using
usize::MAXas a fallback for conversion failures can lead to incorrect delete operation sizes. This needs proper error handling to avoid creating operations with incorrect lengths.@ -116,3 +117,4 @@.text()}fn set_panic_hook() {[nitpick] The nested if-let pattern could be simplified using early returns. Consider checking each parameter separately and returning early for invalid inputs, which would improve readability and reduce nesting.
The
.clone()calls are unnecessary here.try_into()can consume the value directly from indexing. Remove.clone()to avoid unnecessary allocations.