This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit daf2204
committed
Auto merge of rust-lang#91837 - Kobzol:stable-hash-map-avoid-sort, r=the8472
Avoid sorting in hash map stable hashing
Suggested by `@the8472` [here](rust-lang#89404 (comment)). I hope that I understood it right, I replaced the sort with modular multiplication, which should be commutative.
Can I ask for a perf. run? However, locally it didn't help at all. Creating the `StableHasher` all over again is probably slowing it down quite a lot. And using `FxHasher` is not straightforward, because the keys and values only implement `HashStable` (and probably they shouldn't be just hashed via `Hash` anyway for it to actually be stable).
Maybe the `StableHash` interface could be changed somehow to better suppor these scenarios where the hasher is short-lived. Or the `StableHasher` implementation could have variants with e.g. a shorter buffer for these scenarios.1 file changed
+43
-23
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
| 45 | + | |
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
52 | 54 | | |
53 | 55 | | |
54 | 56 | | |
| |||
507 | 509 | | |
508 | 510 | | |
509 | 511 | | |
510 | | - | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
511 | 517 | | |
512 | 518 | | |
513 | 519 | | |
| |||
517 | 523 | | |
518 | 524 | | |
519 | 525 | | |
520 | | - | |
521 | | - | |
522 | | - | |
| 526 | + | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
523 | 530 | | |
524 | 531 | | |
525 | 532 | | |
| |||
529 | 536 | | |
530 | 537 | | |
531 | 538 | | |
532 | | - | |
533 | | - | |
534 | | - | |
535 | | - | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
536 | 544 | | |
537 | 545 | | |
538 | 546 | | |
| |||
541 | 549 | | |
542 | 550 | | |
543 | 551 | | |
544 | | - | |
545 | | - | |
546 | | - | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
547 | 556 | | |
548 | 557 | | |
549 | 558 | | |
550 | | - | |
| 559 | + | |
551 | 560 | | |
552 | 561 | | |
553 | | - | |
554 | | - | |
| 562 | + | |
| 563 | + | |
| 564 | + | |
555 | 565 | | |
556 | | - | |
557 | | - | |
558 | | - | |
559 | | - | |
560 | | - | |
| 566 | + | |
| 567 | + | |
561 | 568 | | |
562 | | - | |
563 | | - | |
564 | | - | |
565 | | - | |
| 569 | + | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
| 573 | + | |
| 574 | + | |
| 575 | + | |
| 576 | + | |
| 577 | + | |
| 578 | + | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
566 | 586 | | |
0 commit comments