Skip to content

Commit

Permalink
Update comments for Read4To8 and Read1To3.
Browse files Browse the repository at this point in the history
The implementations for these functions changed recently to no longer zero pad and instead duplicate input bytes. Also remove a TODO that has been done.

PiperOrigin-RevId: 722793915
Change-Id: Ib5c3d444530270d227ec1636935925acc4d8dc0c
  • Loading branch information
ezbr authored and copybara-github committed Feb 3, 2025
1 parent 30a964d commit ee28392
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions absl/hash/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -1251,11 +1251,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
#endif
}

// Reads 4 to 8 bytes from p. Zero pads to fill uint64_t.
// TODO(b/384509507): consider optimizing this by not requiring the output to
// be equivalent to an integer load for 4/8 bytes. Currently, we rely on this
// behavior for the HashConsistentAcrossIntTypes test case. Ditto for
// Read1To3.
// Reads 4 to 8 bytes from p. Some input bytes may be duplicated in output.
static uint64_t Read4To8(const unsigned char* p, size_t len) {
// If `len < 8`, we duplicate bytes in the middle.
// E.g.:
Expand All @@ -1274,7 +1270,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
return most_significant | least_significant;
}

// Reads 1 to 3 bytes from p. Zero pads to fill uint32_t.
// Reads 1 to 3 bytes from p. Some input bytes may be duplicated in output.
static uint32_t Read1To3(const unsigned char* p, size_t len) {
// The trick used by this implementation is to avoid branches.
// We always read three bytes by duplicating.
Expand Down

0 comments on commit ee28392

Please sign in to comment.