clockworklabs / SpacetimeDB

Multiplayer at the speed of light
https://spacetimedb.com
Other
4.12k stars 100 forks source link

Add `Hash for RowRef` + make it consistent with `Hash for PV` #1163

Closed Centril closed 2 weeks ago

Centril commented 3 weeks ago

Description of Changes

  1. Add Hash for RowRef + make it consistent with Hash for ProductValue.
  2. Make RowRef::row_hash use the above.
  3. Make Table::insert return a RowRef.
  4. Use less unsafe because of 1-3.
  5. Use second-stack to reuse temporary allocations in hashing and serialization.

Fixes https://github.com/clockworklabs/SpacetimeDB/pull/1107.

API and ABI breaking changes

None

Expected complexity level and risk

3, some unsafe involved and we need to ensure consistency in the eq/hash functions. Some unsafe code is also removed.

Testing

Proptests are added for the new code.