caiconghui commented on a change in pull request #8500:
URL: https://github.com/apache/incubator-doris/pull/8500#discussion_r830619822
##########
File path: be/src/olap/types.h
##########
@@ -1193,6 +1208,23 @@ struct TypeTraits : public FieldTypeTraits<field_type> {
static const int32_t size = sizeof(CppType);
};
+// get type at compile time for performance
+// ---- Version_1 ----
+// template <FieldType field_type>
+// extern TypeInfo* get_scalar_type_info_by_template(){
+// static constexpr TypeTraits<field_type> traits;
+// static auto obj = ScalarTypeInfo(traits);
+// static constexpr ScalarTypeInfo* p = &obj;
+// return (TypeInfo*)(p);
+// }
+
+// Version_2
+template <FieldType field_type>
+std::shared_ptr<const TypeInfo> get_scalar_type_info_by_template() {
+ static constexpr TypeTraits<field_type> traits;
+ return std::shared_ptr<const TypeInfo>(new ScalarTypeInfo(traits));
Review comment:
how about define static TypeInfo object and return reference. now, it
seems we need to
create ScalarTypeInfo every function call
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]