[FFmpeg-devel] [PATCH 1/3] avutil/dict2: Add AVDictionary2 with hash-based lookup

Michael Niedermayer michael at niedermayer.cc
Thu Apr 17 00:24:48 EEST 2025


Hi

i like AI and ill reply with more comments about this elsewhere
but as i looked at the code, i had to reply here

[...]

> +/* Get a dictionary entry */
> +AVDictionaryEntry2 *av_dict2_get(const AVDictionary2 *m, const char *key,
> +                               const AVDictionaryEntry2 *prev, int flags) {
> +    unsigned int hash;
> +    int table_idx;
> +    DictEntry *entry;
> +    
> +    static AVDictionaryEntry2 de;  // Return value - holds pointers to internal data
> +    
> +    if (!m || !key)
> +        return NULL;
> +

> +    if (prev)
> +        return NULL;  // 'prev' functionality not implemented

not implemented ?


> +        
> +    // Get hash index

> +    hash = dict_hash(key, m->flags & AV_DICT2_MATCH_CASE);

case sensitivity is supported by having the set funtiom insert with the
case sensitivity that the get function later will use ?


> +    table_idx = hash % m->table_size;
> +    
> +    // Search in chain
> +    for (entry = m->entries[table_idx]; entry; entry = entry->next) {
> +        if ((m->flags & AV_DICT2_MATCH_CASE ? 
> +             !strcmp(entry->key, key) : 
> +             !av_strcasecmp(entry->key, key))) {
> +            
> +            // Found match
> +            de.key = entry->key;
> +            de.value = entry->value;
> +            return &de;

tasty globals for thread saftey

thx

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Take away the freedom of one citizen and you will be jailed, take away
the freedom of all citizens and you will be congratulated by your peers
in Parliament.
-------------- 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/20250416/7a3d1267/attachment.sig>


More information about the ffmpeg-devel mailing list