Skip to content

Optimize memory usage#2

Merged
gregberge merged 5 commits intomainfrom
optimize-memory-usage
Jan 13, 2026
Merged

Optimize memory usage#2
gregberge merged 5 commits intomainfrom
optimize-memory-usage

Conversation

@gregberge
Copy link
Member

  • feat: accept a filepath or a buffer
  • feat: optimize memory usage

@gregberge gregberge requested review from Copilot and removed request for Copilot January 13, 2026 07:57
Copilot AI review requested due to automatic review settings January 13, 2026 07:58
@gregberge gregberge changed the title optimize memory usage Optimize memory usage Jan 13, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR optimizes memory usage in the PNG fingerprinting library by eliminating intermediate buffer allocations and adds support for accepting file paths as input in addition to buffers.

Changes:

  • Refactored fingerprint_diff to accept either a file path (string) or buffer as input
  • Optimized PNG decoding to avoid unnecessary copying for RGBA8 format images
  • Merged the hash computation directly into the grid density calculation to eliminate intermediate buffers (pack_2bit and fnv1a64 functions removed)

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/lib.rs Added filepath/buffer input support, optimized RGBA8 decoding path, and merged packing/hashing into hash_grid_density to eliminate intermediate allocations
index.d.ts Updated TypeScript signature to accept string | Buffer instead of just Buffer
test/index.spec.ts Added test case to verify filepath input produces same fingerprint as buffer input

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@gregberge gregberge merged commit 9322e70 into main Jan 13, 2026
12 checks passed
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