Skip to content

Commit

Permalink
Remove unnecessary template in TEnumTraits
Browse files Browse the repository at this point in the history
Summary:
* It won't improve build-time since `std::string_view` is not dependent type. Compiler will still try to compile the function (e.g., https://godbolt.org/z/f1PhndMnT)
* It won't reduce build-size since `FOLLY_ERASE` will already inline the function.

Reviewed By: createdbysk

Differential Revision: D67615887

fbshipit-source-id: a18445884ee0950fde4d823e005f07366e998905
  • Loading branch information
TJ Yin authored and facebook-github-bot committed Dec 26, 2024
1 parent 111fb5e commit 918558b
Show file tree
Hide file tree
Showing 34 changed files with 0 additions and 132 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,10 @@ template <> struct TEnumTraits<{{> common/namespace_cpp2}}{{enum:cpp_name}}> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "{{enum:name}}";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "{{program:name}}";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -546,12 +546,10 @@ template <> struct TEnumTraits<::facebook::thrift::test::Color> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "Color";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -579,12 +577,10 @@ template <> struct TEnumTraits<::facebook::thrift::test::ThriftAdaptedEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "ThriftAdaptedEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,12 +114,10 @@ template <> struct TEnumTraits<::cpp2::YourEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ template <> struct TEnumTraits<::test::fixtures::enumstrict::EmptyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "EmptyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand All @@ -141,12 +139,10 @@ template <> struct TEnumTraits<::test::fixtures::enumstrict::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -174,12 +170,10 @@ template <> struct TEnumTraits<::test::fixtures::enumstrict::MyUseIntrinsicDefau
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyUseIntrinsicDefaultEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -207,12 +201,10 @@ template <> struct TEnumTraits<::test::fixtures::enumstrict::MyBigEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyBigEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,10 @@ template <> struct TEnumTraits<::cpp2::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,12 +135,10 @@ template <> struct TEnumTraits<::test::fixtures::basic-structured-annotations::M
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,10 @@ template <> struct TEnumTraits<::test::fixtures::basic::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -226,12 +224,10 @@ template <> struct TEnumTraits<::test::fixtures::basic::HackEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "HackEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -601,12 +601,10 @@ template <> struct TEnumTraits<::cpp2::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,10 @@ template <> struct TEnumTraits<::cpp2::EmptyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "EmptyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand All @@ -232,12 +230,10 @@ template <> struct TEnumTraits<::cpp2::City> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "City";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -265,12 +261,10 @@ template <> struct TEnumTraits<::cpp2::Company> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "Company";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,10 @@ template <> struct TEnumTraits<::apache::thrift::test::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,10 @@ template <> struct TEnumTraits<::cpp2::B> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "B";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,12 +263,10 @@ template <> struct TEnumTraits<::apache::thrift::test::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "simple";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,10 @@ template <> struct TEnumTraits<::apache::thrift::test::MyEnum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "simple_deprecated_terse_writes";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,10 @@ template <> struct TEnumTraits<::facebook::thrift::test::Enum> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "Enum";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,12 +230,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::Metasyntactic> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "Metasyntactic";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -263,12 +261,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyEnum1> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum1";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -296,12 +292,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyEnum2> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum2";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -329,12 +323,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyEnum3> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum3";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -362,12 +354,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyEnum4> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyEnum4";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -395,12 +385,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyBitmaskEnum1> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyBitmaskEnum1";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down Expand Up @@ -428,12 +416,10 @@ template <> struct TEnumTraits<::test::fixtures::enums::MyBitmaskEnum2> {
static bool findName(type value, std::string_view* out) noexcept;
static bool findValue(std::string_view name, type* out) noexcept;

template <class ...>
FOLLY_ERASE static std::string_view typeName() noexcept {
return "MyBitmaskEnum2";
}

template <class ...>
FOLLY_ERASE static constexpr std::string_view moduleName() noexcept {
return "module";
}
Expand Down
Loading

0 comments on commit 918558b

Please sign in to comment.