Repository: apache/arrow
File: c_glib/arrow-glib/compute.cpp (C++)

Code before:
  if (priv->characters) {
    g_free(priv->characters);
    priv->characters = nullptr;
  }
  G_OBJECT_CLASS(garrow_trim_options_parent_class)->dispose(object);
}

static void
garrow_trim_options_set_property(GObject *object,
                                 guint prop_id,
                                 const GValue *value,
                                 GParamSpec *pspec)
{
  auto options = garrow_trim_options_get_raw(GARROW_TRIM_OPTIONS(object));
  auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE(object);

  switch (prop_id) {
  case PROP_TRIM_OPTIONS_CHARACTERS:
    {
      const gchar *characters = g_value_get_string(value);
      if (priv->characters) {
        g_free(priv->characters);
      }
      priv->characters = g_strdup(characters);
      options->characters = characters ? characters : "";
    }
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
    break;
  }
}

static void
garrow_trim_options_get_property(GObject *object,
                                 guint prop_id,
                                 GValue *value,
                                 GParamSpec *pspec)
{
  auto options = garrow_trim_options_get_raw(GARROW_TRIM_OPTIONS(object));
  auto priv = GARROW_TRIM_OPTIONS_GET_PRIVATE(object);

  switch (prop_id) {
  case PROP_TRIM_OPTIONS_CHARACTERS:
    g_value_set_string(value,
                       priv->characters ? priv->characters : options->characters.c_str());
    break;
  default:
    G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
    break;
  }

Review comment (refactor):
Can we simplify this?

```suggestion
    options->characters = g_value_get_string(value);
```

Code after:
   * Since: 23.0.0
   */
  spec = g_param_spec_uint("week-start",
                           "Week start",
                           "What day does the week start with (Monday=1, Sunday=7). The "
                           "numbering is unaffected by the count_from_zero parameter",
                           1,
                           7,
                           options.week_start,
                           static_cast<GParamFlags>(G_PARAM_READWRITE));
  g_object_class_install_property(gobject_class,
                                  PROP_DAY_OF_WEEK_OPTIONS_WEEK_START,
                                  spec);
}

/**
 * garrow_day_of_week_options_new:
 *
 * Returns: A newly created #GArrowDayOfWeekOptions.
 *
 * Since: 23.0.0
 */
GArrowDayOfWeekOptions *
garrow_day_of_week_options_new(void)
{
  auto options = g_object_new(GARROW_TYPE_DAY_OF_WEEK_OPTIONS, NULL);
  return GARROW_DAY_OF_WEEK_OPTIONS(options);
}

enum {
  PROP_EXTRACT_REGEX_OPTIONS_PATTERN = 1,
};

G_DEFINE_TYPE(GArrowExtractRegexOptions,
              garrow_extract_regex_options,
              GARROW_TYPE_FUNCTION_OPTIONS)

static void
garrow_extract_regex_options_set_property(GObject *object,
                                          guint prop_id,
                                          const GValue *value,
                                          GParamSpec *pspec)
{
  auto options =
    garrow_extract_regex_options_get_raw(GARROW_EXTRACT_REGEX_OPTIONS(object));

  switch (prop_id) {
  case PROP_EXTRACT_REGEX_OPTIONS_PATTERN:
    options->pattern = g_value_get_string(value);
    break;
  default: