Skip to content

Commit f5f12e9

Browse files
author
dtorilov
committed
Revert "YT-21306: Add EnumHasDefaultValue"
This reverts commit d9b67f1778da2d15dd94f7285afe4e3490a233ab, reversing changes made to 461a09e0c18bd14cef7df8060e7f9537e3ad74b5. 92cdaf4185661b7058f6a30d5a532ad40b725345
1 parent 8adfc2f commit f5f12e9

File tree

7 files changed

+4
-44
lines changed

7 files changed

+4
-44
lines changed

library/cpp/yt/misc/cast-inl.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,6 @@ T CheckedEnumCast(S value)
124124
{
125125
T result;
126126
if (!TryEnumCast<T>(value, &result)) {
127-
if constexpr (TEnumHasDefaultValue<T>::value) {
128-
return GetDefaultValue(T{});
129-
}
130-
131127
throw TSimpleException(Sprintf("Error casting %s value \"%d\" to enum %s",
132128
TypeName<S>().c_str(),
133129
static_cast<int>(value),

library/cpp/yt/misc/enum.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,20 +197,6 @@ constexpr bool None(E value) noexcept;
197197

198198
////////////////////////////////////////////////////////////////////////////////
199199

200-
template <typename E, typename = void>
201-
requires TEnumTraits<E>::IsEnum
202-
struct TEnumHasDefaultValue
203-
: std::false_type
204-
{ };
205-
206-
template <typename E>
207-
requires TEnumTraits<E>::IsEnum
208-
struct TEnumHasDefaultValue<E, std::void_t<decltype(GetDefaultValue(std::declval<E>()))>>
209-
: std::is_same<decltype(GetDefaultValue(std::declval<E>())), E>
210-
{ };
211-
212-
////////////////////////////////////////////////////////////////////////////////
213-
214200
} // namespace NYT
215201

216202
#define ENUM_INL_H_

library/cpp/yt/string/enum-inl.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ T ParseEnum(TStringBuf value)
8787
if (auto optionalResult = TryParseEnum<T>(value)) {
8888
return *optionalResult;
8989
}
90-
91-
if constexpr (TEnumHasDefaultValue<T>::value) {
92-
return GetDefaultValue(T{});
93-
}
94-
9590
NYT::NDetail::ThrowMalformedEnumValueException(TEnumTraits<T>::GetTypeName(), value);
9691
}
9792

yt/yt/core/bus/public.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,5 @@ const TString LocalNetworkName("local");
99

1010
////////////////////////////////////////////////////////////////////////////////
1111

12-
EMultiplexingBand GetDefaultValue(EMultiplexingBand)
13-
{
14-
return EMultiplexingBand::Default;
15-
}
16-
17-
////////////////////////////////////////////////////////////////////////////////
18-
1912
} // namespace NYT::NBus
13+

yt/yt/core/bus/public.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ DEFINE_ENUM(EMultiplexingBand,
3636
((RealTime) (4))
3737
);
3838

39-
EMultiplexingBand GetDefaultValue(EMultiplexingBand);
40-
4139
YT_DEFINE_ERROR_ENUM(
4240
((TransportError) (100))
4341
((SslError) (119))
@@ -61,3 +59,4 @@ extern const TString LocalNetworkName;
6159
////////////////////////////////////////////////////////////////////////////////
6260

6361
} // namespace NYT::NBus
62+

yt/yt/core/misc/protobuf_helpers-inl.h

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,7 @@ template <class T>
181181
requires TEnumTraits<T>::IsEnum && (!TEnumTraits<T>::IsBitEnum)
182182
void FromProto(T* original, int serialized)
183183
{
184-
if constexpr (TEnumHasDefaultValue<T>::value) {
185-
*original = CheckedEnumCast<T>(serialized);
186-
} else {
187-
*original = static_cast<T>(serialized);
188-
}
184+
*original = static_cast<T>(serialized);
189185
}
190186

191187
template <class T>
@@ -199,11 +195,7 @@ template <class T>
199195
requires TEnumTraits<T>::IsBitEnum
200196
void FromProto(T* original, ui64 serialized)
201197
{
202-
if constexpr (TEnumHasDefaultValue<T>::value) {
203-
*original = CheckedEnumCast<T>(serialized);
204-
} else {
205-
*original = static_cast<T>(serialized);
206-
}
198+
*original = static_cast<T>(serialized);
207199
}
208200

209201
////////////////////////////////////////////////////////////////////////////////

yt/yt_proto/yt/client/api/rpc_proxy/proto/api_service.proto

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ enum EMultiplexingBand
225225
MB_CONTROL = 1;
226226
MB_HEAVY = 2;
227227
MB_INTERACTIVE = 3;
228-
MB_REAL_TIME = 4;
229-
MB_JOURNAL = 5;
230228
}
231229

232230
enum ETableSchemaModification

0 commit comments

Comments
 (0)