kou commented on a change in pull request #12041:
URL: https://github.com/apache/arrow/pull/12041#discussion_r776869489



##########
File path: c_glib/arrow-glib/scalar.cpp
##########
@@ -2039,6 +2039,16 @@ GList *
 garrow_struct_scalar_get_value(GArrowStructScalar *scalar)
 {
   auto priv = GARROW_STRUCT_SCALAR_GET_PRIVATE(scalar);
+  if (!priv->value) {
+    auto arrow_scalar =
+      std::static_pointer_cast<arrow::StructScalar>(
+        garrow_scalar_get_raw(GARROW_SCALAR(scalar)));
+    for (auto arrow_element : arrow_scalar->value) {
+      priv->value = g_list_prepend(priv->value,
+                                   garrow_scalar_new_raw(&arrow_element));
+    }
+    priv->value = g_list_reverse(priv->value);
+  }

Review comment:
       This is a idiom in GLib. This is for performance but this will not be 
needed here.
   
   `GList` is a linked list. `g_list_append()` is O(N) (N is the number of 
elements). `g_list_prepend()` is O(1). `g_list_reverse()` is O(N).




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