pw_kvs: Replace string_view with custom type
Create a new type 'Key' which behaves the same as string_view but
doesn't require C++17.
Test: Passes all tests.
Change-Id: I2ebadbb0405f3fa3520dad46ea500cafe652f230
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/27140
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Rob Oliver <rgoliver@google.com>
diff --git a/pw_kvs/entry_cache.cc b/pw_kvs/entry_cache.cc
index 9fa93a2..c63e349 100644
--- a/pw_kvs/entry_cache.cc
+++ b/pw_kvs/entry_cache.cc
@@ -28,8 +28,6 @@
namespace pw::kvs::internal {
namespace {
-using std::string_view;
-
constexpr FlashPartition::Address kNoAddress = FlashPartition::Address(-1);
} // namespace
@@ -64,7 +62,7 @@
StatusWithSize EntryCache::Find(FlashPartition& partition,
const Sectors& sectors,
const EntryFormats& formats,
- string_view key,
+ Key key,
EntryMetadata* metadata) const {
const uint32_t hash = internal::Hash(key);
Entry::KeyBuffer key_buffer;
@@ -73,13 +71,13 @@
for (size_t i = 0; i < descriptors_.size(); ++i) {
if (descriptors_[i].key_hash == hash) {
bool key_found = false;
- string_view read_key;
+ Key read_key;
for (Address address : addresses(i)) {
Status read_result =
Entry::ReadKey(partition, address, key.size(), key_buffer.data());
- read_key = string_view(key_buffer.data(), key.size());
+ read_key = Key(key_buffer.data(), key.size());
if (read_result.ok() && hash == internal::Hash(read_key)) {
key_found = true;