Skip to content

Commit

Permalink
Merge pull request #1388 from miladfarca:fix-Read1To3-on-BE
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 511499093
Change-Id: I9ea2bbc38cbe8bd9dae937626d8faac41c010b38
  • Loading branch information
copybara-github committed Feb 22, 2023
2 parents c3b5022 + 32794f0 commit d6ea4df
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion absl/hash/internal/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {

// Reads 1 to 3 bytes from p. Zero pads to fill uint32_t.
static uint32_t Read1To3(const unsigned char* p, size_t len) {
// The trick used by this implementation is to avoid branches if possible.
unsigned char mem0 = p[0];
unsigned char mem1 = p[len / 2];
unsigned char mem2 = p[len - 1];
Expand All @@ -1083,7 +1084,7 @@ class ABSL_DLL MixingHashState : public HashStateBase<MixingHashState> {
unsigned char significant0 = mem0;
#else
unsigned char significant2 = mem0;
unsigned char significant1 = mem1;
unsigned char significant1 = len == 2 ? mem0 : mem1;
unsigned char significant0 = mem2;
#endif
return static_cast<uint32_t>(significant0 | //
Expand Down

0 comments on commit d6ea4df

Please sign in to comment.