pull/28109/head
Craig Tiller 3 years ago
parent 282b9f6217
commit f32bb83f9f
  1. 46
      src/core/ext/transport/chttp2/transport/hpack_parser.cc
  2. 3
      src/core/lib/slice/slice.h

@ -683,10 +683,12 @@ class HPackParser::String {
return p->as_string_view();
}
if (auto* p = absl::get_if<absl::Span<const uint8_t>>(&value_)) {
return absl::string_view(reinterpret_cast<const char*>(p->data()), p->size());
return absl::string_view(reinterpret_cast<const char*>(p->data()),
p->size());
}
if (auto* p = absl::get_if<std::vector<uint8_t>>(&value_)) {
return absl::string_view(reinterpret_cast<const char*>(p->data()), p->size());
return absl::string_view(reinterpret_cast<const char*>(p->data()),
p->size());
}
abort();
GPR_UNREACHABLE_CODE(return absl::string_view());
@ -1240,30 +1242,30 @@ class HPackParser::Parser {
};
Slice HPackParser::String::Take(Extern) {
if (auto* p = absl::get_if<Slice>(&value_)) {
return std::move(*p);
}
if (auto* p = absl::get_if<absl::Span<const uint8_t>>(&value_)) {
return Slice::FromCopiedBuffer(*p);
}
if (auto* p = absl::get_if<std::vector<uint8_t>>(&value_)) {
return Slice::FromCopiedBuffer(*p);
}
abort();
GPR_UNREACHABLE_CODE(return Slice());
if (auto* p = absl::get_if<Slice>(&value_)) {
return std::move(*p);
}
if (auto* p = absl::get_if<absl::Span<const uint8_t>>(&value_)) {
return Slice::FromCopiedBuffer(*p);
}
if (auto* p = absl::get_if<std::vector<uint8_t>>(&value_)) {
return Slice::FromCopiedBuffer(*p);
}
abort();
GPR_UNREACHABLE_CODE(return Slice());
}
Slice HPackParser::String::Take(Intern) {
ManagedMemorySlice m;
ManagedMemorySlice m;
if (auto* p = absl::get_if<Slice>(&value_)) {
m = ManagedMemorySlice(&p->c_slice());
}
if (auto* p = absl::get_if<absl::Span<const uint8_t>>(&value_)) {
m = ManagedMemorySlice(reinterpret_cast<const char*>(p->data()), p->size());
}
if (auto* p = absl::get_if<std::vector<uint8_t>>(&value_)) {
m = ManagedMemorySlice(reinterpret_cast<const char*>(p->data()), p->size());
}
m = ManagedMemorySlice(&p->c_slice());
}
if (auto* p = absl::get_if<absl::Span<const uint8_t>>(&value_)) {
m = ManagedMemorySlice(reinterpret_cast<const char*>(p->data()), p->size());
}
if (auto* p = absl::get_if<std::vector<uint8_t>>(&value_)) {
m = ManagedMemorySlice(reinterpret_cast<const char*>(p->data()), p->size());
}
return Slice(m);
}

@ -164,7 +164,8 @@ struct CopyConstructors {
}
template <typename Buffer>
static Out FromCopiedBuffer(const Buffer& buffer) {
return Out(UnmanagedMemorySlice(reinterpret_cast<const char*>(buffer.data()), buffer.size()));
return Out(UnmanagedMemorySlice(
reinterpret_cast<const char*>(buffer.data()), buffer.size()));
}
};

Loading…
Cancel
Save