You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
71 lines
2.8 KiB
71 lines
2.8 KiB
3 years ago
|
diff -up chromium-92.0.4515.107/components/cast_channel/enum_table.h.EnumTable-crash chromium-92.0.4515.107/components/cast_channel/enum_table.h
|
||
|
--- chromium-92.0.4515.107/components/cast_channel/enum_table.h.EnumTable-crash 2021-07-19 14:45:12.000000000 -0400
|
||
|
+++ chromium-92.0.4515.107/components/cast_channel/enum_table.h 2021-07-26 17:41:21.987375385 -0400
|
||
|
@@ -212,7 +212,7 @@ class
|
||
|
|
||
|
template <typename E>
|
||
|
friend class EnumTable;
|
||
|
- DISALLOW_COPY_AND_ASSIGN(GenericEnumTableEntry);
|
||
|
+ DISALLOW_ASSIGN(GenericEnumTableEntry);
|
||
|
};
|
||
|
|
||
|
// Yes, these constructors really needs to be inlined. Even though they look
|
||
|
@@ -250,8 +250,7 @@ class EnumTable {
|
||
|
// Constructor for regular entries.
|
||
|
constexpr Entry(E value, base::StringPiece str)
|
||
|
: GenericEnumTableEntry(static_cast<int32_t>(value), str) {}
|
||
|
-
|
||
|
- DISALLOW_COPY_AND_ASSIGN(Entry);
|
||
|
+ DISALLOW_ASSIGN(Entry);
|
||
|
};
|
||
|
|
||
|
static_assert(sizeof(E) <= sizeof(int32_t),
|
||
|
@@ -306,15 +305,14 @@ class EnumTable {
|
||
|
if (is_sorted_) {
|
||
|
const std::size_t index = static_cast<std::size_t>(value);
|
||
|
if (ANALYZER_ASSUME_TRUE(index < data_.size())) {
|
||
|
- const auto& entry = data_.begin()[index];
|
||
|
+ const auto& entry = data_[index];
|
||
|
if (ANALYZER_ASSUME_TRUE(entry.has_str()))
|
||
|
return entry.str();
|
||
|
}
|
||
|
return absl::nullopt;
|
||
|
}
|
||
|
return GenericEnumTableEntry::FindByValue(
|
||
|
- reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
|
||
|
- data_.size(), static_cast<int32_t>(value));
|
||
|
+ &data_[0], data_.size(), static_cast<int32_t>(value));
|
||
|
}
|
||
|
|
||
|
// This overload of GetString is designed for cases where the argument is a
|
||
|
@@ -342,8 +340,7 @@ class EnumTable {
|
||
|
// enum value directly.
|
||
|
absl::optional<E> GetEnum(base::StringPiece str) const {
|
||
|
auto* entry = GenericEnumTableEntry::FindByString(
|
||
|
- reinterpret_cast<const GenericEnumTableEntry*>(data_.begin()),
|
||
|
- data_.size(), str);
|
||
|
+ &data_[0], data_.size(), str);
|
||
|
return entry ? static_cast<E>(entry->value) : absl::optional<E>();
|
||
|
}
|
||
|
|
||
|
@@ -358,7 +355,7 @@ class EnumTable {
|
||
|
// Align the data on a cache line boundary.
|
||
|
alignas(64)
|
||
|
#endif
|
||
|
- std::initializer_list<Entry> data_;
|
||
|
+ const std::vector<Entry> data_;
|
||
|
bool is_sorted_;
|
||
|
|
||
|
constexpr EnumTable(std::initializer_list<Entry> data, bool is_sorted)
|
||
|
@@ -370,8 +367,8 @@ class EnumTable {
|
||
|
|
||
|
for (std::size_t i = 0; i < data.size(); i++) {
|
||
|
for (std::size_t j = i + 1; j < data.size(); j++) {
|
||
|
- const Entry& ei = data.begin()[i];
|
||
|
- const Entry& ej = data.begin()[j];
|
||
|
+ const Entry& ei = data[i];
|
||
|
+ const Entry& ej = data[j];
|
||
|
DCHECK(ei.value != ej.value)
|
||
|
<< "Found duplicate enum values at indices " << i << " and " << j;
|
||
|
DCHECK(!(ei.has_str() && ej.has_str() && ei.str() == ej.str()))
|