[FFmpeg-devel] [PATCH v3] libavutil: Add AVMap
Leo Izen
leo.izen at gmail.com
Fri Apr 18 17:46:42 EEST 2025
On 4/17/25 16:12, Michael Niedermayer wrote:
>>
>>> + * @param keyvalue_cmp compare function, will be passed the key + value concatenated.
>>
>> Please no. Pass the key and the value separately to the compare
>> function.
>
> thats neither efficient nor does it fit the existing APIs.
> The value is most of the time not used and when used it is known exactly
> where it is. after a string compare of the key thats equal the value location is known
> or with arbitrary binary data the compare function knows the size of the data.
> Passing redudant pointers just wastes cpu cycles
> also existing APIs from av_tree strcmp() av_strcasecmp() and so on none of
> which take 4 pointers from which they would ignore 2.
>
The problem is that passing the key and value pairs combined requires
you to concatenate them. Since AVMapEntry has two separate pointers *key
and *value, it doesn't make sense to concatenate them before comparison
rather than just pass the pointers as-is.
- Leo Izen (Traneptora)
More information about the ffmpeg-devel
mailing list