[FFmpeg-devel] [PATCH v3] libavutil: Add AVMap

Michael Niedermayer michael at niedermayer.cc
Sat Apr 19 04:23:12 EEST 2025


On Fri, Apr 18, 2025 at 10:46:42AM -0400, Leo Izen wrote:
> 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.

AVMapEntry.key and value are always concatenate already

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Nations do behave wisely once they have exhausted all other alternatives. 
-- Abba Eban
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20250419/d7b53c89/attachment.sig>


More information about the ffmpeg-devel mailing list