On Tue, Apr 08, 2025 at 08:00:20PM -0400, Leo Izen wrote: > On 4/8/25 06:19, Michael Niedermayer wrote: > > Hi all > > > > As i have too many things to do already i did the most logic thing and > > started thinking about a new and unrelated idea. > > > > This is a list of problems and ideas, that everyone is welcome to add to and > > comment on. > > > > AVDictionary is just bad. > > > > * its complicated internally with > > unneeded alternative (AV_DICT_DONT_STRDUP_VAL/KEY) these are rarely used > > and probably not relevant for performance. > > > > As far as I'm aware the main purpose of AV_DICT_DONT_STRDUP is to transfer > ownership to the dictionary to save a call to malloc/free. If I construct a > string e.g. with av_bprint API, and then I want to pass it as a value to an > AVDictionary *, then without access to AV_DICT_DONT_STRDUP_VAL as an option, > I will then have to free it. > > Since your goal is to avoid malloc/free calls I feel like this is a > reasonable interface to continue to support.
git grep av_dict_set | wc is 690 git grep AV_DICT_DONT_STRDUP | wc is 87 git grep AV_DICT_DONT_STRDUP libavutil/ tests doc | wc is 20 We thus have 67 cases using one of the AV_DICT_DONT_STRDUP and ~ 623 which do not and we need 2*623 mallocs and 623 + 67 reallocs ATM (not counting the ones outside av_dict_set()) teh proposed system would use 623 + 67 mallocs and 67 free and log2(623 + 67) realloc. (or less if one used a single array) It also could potentially avoid some of teh mallocs done outside that just get freed then inside now if you continue or not continue to support AV_DICT_DONT_STRDUP doesnt change anything. The 2 externally allocated strings are not in the right format and need to be freed. And even with freeing its fewer mallocs (as shown above) also the implied minimum allocation from AV_DICT_DONT_STRDUP is 2 per call, we only need 1 with no extra complexity. Just dont allocate 2 seperate arrays, use 1 as a bonus its also 1 pointer less and 1 free less thx [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB If a bugfix only changes things apparently unrelated to the bug with no further explanation, that is a good sign that the bugfix is wrong.
signature.asc
Description: PGP signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".