зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1728769 - Use std::underlying_type_t for profile buffer enum types r=canaltinova
This patch replaces "custom" underlying type definitions with definitions gleaned using the std::underlying_type mechanism. This allows us to directly set the underlying type for the enums without having to name it, and reduces the number of semantically identical names in the profile buffer code. Differential Revision: https://phabricator.services.mozilla.com/D174260
This commit is contained in:
Родитель
d3cdd3192f
Коммит
82c01addf1
|
@ -19,13 +19,15 @@
|
|||
#include "mozilla/Vector.h"
|
||||
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla {
|
||||
namespace baseprofiler {
|
||||
|
||||
class ProfileBufferEntry {
|
||||
public:
|
||||
using KindUnderlyingType = ::mozilla::ProfileBufferEntryKindUnderlyingType;
|
||||
using KindUnderlyingType =
|
||||
std::underlying_type_t<::mozilla::ProfileBufferEntryKind>;
|
||||
using Kind = ::mozilla::ProfileBufferEntryKind;
|
||||
|
||||
ProfileBufferEntry();
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include <limits>
|
||||
#include <tuple>
|
||||
#include <type_traits>
|
||||
|
||||
namespace mozilla::baseprofiler {
|
||||
// Implemented in platform.cpp
|
||||
|
@ -407,8 +408,8 @@ void DeserializeAfterKindAndStream(
|
|||
}
|
||||
|
||||
auto payloadType = static_cast<mozilla::MarkerPayloadType>(
|
||||
aEntryReader
|
||||
.ReadObject<mozilla::MarkerPayloadTypeUnderlyingType>());
|
||||
aEntryReader.ReadObject<
|
||||
std::underlying_type_t<mozilla::MarkerPayloadType>>());
|
||||
|
||||
// Stream the payload, including the type.
|
||||
switch (payloadType) {
|
||||
|
|
|
@ -60,9 +60,7 @@ static constexpr size_t ProfileBufferEntryNumChars = 8;
|
|||
// more efficient kinds of entries (e.g., stack frames could be stored in one
|
||||
// bigger entry, instead of multiple `ProfileBufferEntry`s); then we could
|
||||
// discard `ProfileBufferEntry` and move this enum to a more appropriate spot.
|
||||
using ProfileBufferEntryKindUnderlyingType = uint8_t;
|
||||
|
||||
enum class ProfileBufferEntryKind : ProfileBufferEntryKindUnderlyingType {
|
||||
enum class ProfileBufferEntryKind : uint8_t {
|
||||
INVALID = 0,
|
||||
#define KIND(KIND, TYPE, SIZE) KIND,
|
||||
FOR_EACH_PROFILE_BUFFER_ENTRY_KIND(KIND)
|
||||
|
@ -97,8 +95,7 @@ enum class ProfileBufferEntryKind : ProfileBufferEntryKindUnderlyingType {
|
|||
MODERN_LIMIT
|
||||
};
|
||||
|
||||
using MarkerPayloadTypeUnderlyingType = uint8_t;
|
||||
enum class MarkerPayloadType : MarkerPayloadTypeUnderlyingType {
|
||||
enum class MarkerPayloadType : uint8_t {
|
||||
Cpp,
|
||||
Rust,
|
||||
};
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include "gtest/MozGtestFriend.h"
|
||||
#include "js/ProfilingCategory.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
|
@ -30,7 +31,8 @@ struct JSContext;
|
|||
|
||||
class ProfileBufferEntry {
|
||||
public:
|
||||
using KindUnderlyingType = mozilla::ProfileBufferEntryKindUnderlyingType;
|
||||
using KindUnderlyingType =
|
||||
std::underlying_type_t<::mozilla::ProfileBufferEntryKind>;
|
||||
using Kind = mozilla::ProfileBufferEntryKind;
|
||||
|
||||
ProfileBufferEntry();
|
||||
|
|
Загрузка…
Ссылка в новой задаче