Copilot commented on code in PR #49969:
URL: https://github.com/apache/arrow/pull/49969#discussion_r3230063484


##########
c_glib/arrow-glib/basic-data-type.cpp:
##########
@@ -2720,16 +2734,25 @@ 
garrow_data_type_new_raw(std::shared_ptr<arrow::DataType> *arrow_data_type)
     type = GARROW_TYPE_DURATION_DATA_TYPE;
     break;
   case arrow::Type::type::EXTENSION:
+    type = GARROW_TYPE_UNKNOWN_EXTENSION_DATA_TYPE;
     {
-      auto g_extension_data_type =
-        std::static_pointer_cast<garrow::GExtensionType>(*arrow_data_type);
-      if (g_extension_data_type) {
-        auto garrow_data_type = g_extension_data_type->garrow_data_type();
-        g_object_ref(garrow_data_type);
-        return GARROW_DATA_TYPE(garrow_data_type);
+      auto arrow_extension_data_type =
+        std::dynamic_pointer_cast<arrow::ExtensionType>(*arrow_data_type);

Review Comment:
   In the EXTENSION case, `*arrow_data_type` is already known (via `id() == 
arrow::Type::EXTENSION`) to be an `arrow::ExtensionType`, so 
`std::dynamic_pointer_cast<arrow::ExtensionType>` is redundant and introduces 
RTTI overhead plus a potential nullptr dereference if assumptions ever change. 
Prefer `std::static_pointer_cast<arrow::ExtensionType>` here (and keep the 
`dynamic_pointer_cast` only for the `garrow::GExtensionType` check).
   



-- 
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]

Reply via email to