Conversation
0ecf967 to
0c7f571
Compare
There was a problem hiding this comment.
Pull request overview
This PR aims to optimize memory usage in the image fingerprinting code by introducing memory limits, removing the integral image approach, and implementing early buffer cleanup strategies.
Changes:
- Added
max_bytesconfiguration option with validation (minimum 1MB) - Replaced integral image algorithm with direct cell counting in
hash_grid_density_no_integral - Implemented early RGBA buffer cleanup in
fingerprint_rgba_for_equality_owned - Added
FingerprintDiffTaskstruct for async processing (incomplete) - Removed
build_integral_image,rect_sum, andget_integralfunctions
Reviewed changes
Copilot reviewed 1 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/lib.rs | Core memory optimization changes including max_bytes option, new hash algorithm without integral images, early buffer cleanup, and incomplete refactoring of fingerprint_diff function |
| index.d.ts | Added maxBytes optional property to JsEqualityFingerprintOptions interface |
Comments suppressed due to low confidence (1)
src/lib.rs:233
- The function references variables and enum variants that don't exist in the current code path. After the match expression at lines 214-224, the code tries to destructure 'input' using InputBytes::File and InputBytes::Buffer (lines 227-228), but these variants don't match either the local enum definition (lines 209-212) or the module-level enum (lines 158-161). Additionally, line 231 calls decode_png_to_rgba with png_bytes (a slice), but the new signature expects a BufReader. Line 233 calls fingerprint_rgba_for_equality which no longer exists - it was renamed to fingerprint_rgba_for_equality_owned and now takes ownership of the rgba vector.
let png_bytes: &[u8] = match &input {
InputBytes::File(bytes) => bytes.as_slice(),
InputBytes::Buffer(buffer) => buffer.as_ref(),
};
let (rgba, width, height) = decode_png_to_rgba(png_bytes)?;
let opts = build_options(options)?;
Ok(fingerprint_rgba_for_equality(&rgba, width, height, &opts))
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
0c7f571 to
26bcdcb
Compare
26bcdcb to
7d1bd33
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.