Re: [PATCH 1/4] core: introduced grl_metadata_source_may_resolve() and corresponding vmethod.



On 21/02/2011 16:37, Juan A. Suárez Romero wrote:
> On Thu, 2011-02-17 at 23:39 +0100, Guillaume Emont wrote:
>>  
>> +/**
>> +  * Will intersect two lists, providing either the intersection in
>> +  * @intersection, the difference (the list of elements in setA and not in
>> +  * setB) in @difference or both, depending on whether any of them is @NULL.
>> +  *
>> +  * intersect_lists (A, B, I, D) is equivalent to:
>> +  * I = g_list_copy (A);
>> +  * D = filter_key_list (some_source, &I, TRUE, B)
>> +  */
>
> I find a bit weird that documentation makes reference to a deprecated
> function.
>
> I think it should be the other way around: filter_key_list() should
> explain how to use intersect_lists() to get the same result.
>
True, will try to do that.
>> +
>> +/**
>> + * @data: a GrlData instance
>> + * @deps: a list of GrlKeyID
>> + *
>> + * Returns: a list of all the keys that are in deps but are not defined in data
>> + */
>> +static GList *
>> +missing_in_data (GrlData *data, const GList *deps)
>> +{
>> +  GList *present_keys, *iter, *known_keys, *result = NULL;
>> +  GRL_DEBUG ("missing_in_data");
>> +
>> +  present_keys = grl_data_get_keys (data);
>> +  known_keys = g_list_copy (present_keys);
>> +
>> +  for (iter = present_keys; iter; iter = g_list_next (iter)) {
>> +    const GrlKeyID key = iter->data;
>> +    if (!grl_data_key_is_known (data, key))
>> +      known_keys = g_list_remove (known_keys, key);
>> +  }
>> +
>> +  intersect_lists (deps, known_keys, NULL, &result);
>> +
>> +  g_list_free (present_keys);
>> +  g_list_free (known_keys);
>> +
>> +  return result;
>> +}
>
> I find this function somewhat complicated, maybe I'm missing
> something....
>
> Shouldn't be easier to do
>
> foreach key in deps;
>   if grl_data_key_is_known(data, key) == FALSE then
>       missing_list = g_list_append (missing_list, key);
>
> return missing_list;
>
You are right, much simpler code fore the same result.

I will post shortly a new version with that corrected, as well as
another issue I found while testing plugin things.

Guij


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