[Vala] Returning StringBuilder.str in functions causes unnecessary strdup().



Hello,
I examined the code generated by vala and found a problem.
Vala does an unnecessary g_strdup() call if I return StringBuilder.str as
return value.
For example:

function string get_str() {
  var str = new StringBuilder();
  str.append("some stuff");
  return str.str
}

Ideally this should generate
return g_string_free(str, FALSE);

but currently vala returns something like
result = g_strdup(str.str);
g_string_free(str, TRUE);
return result;

Apparently, this causes a unnecessary strdup() call.
Is it possible to return g_string_free(str, FALSE) instead?
Maybe I missed some ownership transfer thing?

Thanks


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]