Internal refactor

PiperOrigin-RevId: 727057179
This commit is contained in:
Guogang Li
2025-02-14 14:07:18 -08:00
committed by Copybara-Service
parent 60d5fe440e
commit eea3441da9
12 changed files with 116 additions and 142 deletions
+4 -5
View File
@@ -14,13 +14,12 @@
#include "internal/platform/byte_utils.h"
#include <cstdint>
#include <cstdlib>
#include <string>
#include "absl/strings/str_format.h"
#include "internal/platform/base_input_stream.h"
#include "internal/platform/byte_array.h"
#include "internal/platform/stream_reader.h"
namespace nearby {
@@ -28,9 +27,9 @@ std::string ByteUtils::ToFourDigitString(ByteArray& bytes) {
int multiplier = 1;
int hashCode = 0;
BaseInputStream base_input_stream{bytes};
while (base_input_stream.IsAvailable(1)) {
auto byte = base_input_stream.ReadInt8().value_or(0);
StreamReader stream_reader{bytes};
while (stream_reader.IsAvailable(1)) {
auto byte = stream_reader.ReadInt8().value_or(0);
hashCode = (hashCode + byte * multiplier) % kHashBasePrime;
multiplier = multiplier * kHashBaseMultiplier % kHashBasePrime;
}