Commit ff7865d
committed
store: Add fast collision detection for FNV-1a 64-bit hashes
Add size-based collision detection when storing clipboard entries with
duplicate hashes. If two entries have the same FNV-1a hash but different
sizes, return -EFAULT to indicate a definite hash collision. This is
very cheap.
With:
- Max clips: 1000
- Hash space: 2^64
- Collision probability (birthday paradox): ~2.71 × 10^-14 (about one in
forty trillion)
...this is extremely unlikely, but since we can deal with it cheaply,
just do it.
All documented FNV-1a 64-bit collisions with identical sizes are
artificially constructed. No naturally occurring same-size collisions
are known.
Fixes #252.1 parent 3ff2fb6 commit ff7865d
1 file changed
+8
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
410 | 410 | | |
411 | 411 | | |
412 | 412 | | |
| 413 | + | |
413 | 414 | | |
414 | 415 | | |
415 | 416 | | |
| |||
432 | 433 | | |
433 | 434 | | |
434 | 435 | | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
435 | 442 | | |
436 | 443 | | |
437 | 444 | | |
| |||
451 | 458 | | |
452 | 459 | | |
453 | 460 | | |
454 | | - | |
| 461 | + | |
455 | 462 | | |
456 | 463 | | |
457 | 464 | | |
| |||
0 commit comments